
FastAPI + GliNER
by marimo team
Demo showing GliNER v2 for zero-shot entity extraction, runnable as webapp, API, or CLI.
About this notebook
This notebook runs a named entity extraction demo with the GLiNER2 model. It loads the pretrained model "fastino/gliner2-base-v1" through the gliner2 library. The main libraries are marimo, fastapi, pydantic, gliner2, and wigglystuff. You give the model free text and a list of entity types. The model then returns the entities it finds. The model can run locally on a CPU and it handles zero-shot tasks.
You type text into a text area. You edit the entity types in a sortable list widget from wigglystuff. The list starts with "location" and "person". You can add, remove, or rename entries in the list. The notebook reads the text and the entity list, calls the model, and shows the result as formatted JSON below the inputs.
The same notebook runs in three modes. As an interactive app it uses the widgets described above. As a FastAPI service it exposes a POST route at "/extract/" plus health check routes. As a command line script it reads --text and --entities arguments. A pydantic BaseModel named ModelInput validates the text and entity fields in all three modes. Two pytest tests check the health routes and one extraction call through a FastAPI TestClient.
Related notebooks











