{"id":14964791,"url":"https://github.com/jndiogo/sibila","last_synced_at":"2025-06-16T12:32:43.940Z","repository":{"id":220718714,"uuid":"751042177","full_name":"jndiogo/sibila","owner":"jndiogo","description":"Extract structured data from local or remote LLM models","archived":false,"fork":false,"pushed_at":"2024-06-21T16:08:25.000Z","size":4579,"stargazers_count":41,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-23T09:41:51.626Z","etag":null,"topics":["ai","dataclasses","gguf","gpt","large-language-models","llamacpp","llm-inference","local-ai","local-models","openai","pydantic","python","structured-data","structured-extraction","structured-generation"],"latest_commit_sha":null,"homepage":"https://jndiogo.github.io/sibila/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jndiogo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-31T20:21:46.000Z","updated_at":"2025-03-21T03:49:30.000Z","dependencies_parsed_at":"2024-03-16T22:37:20.809Z","dependency_job_id":"638b2ab7-a73a-4fdb-8cfb-4fc6154d5dbb","html_url":"https://github.com/jndiogo/sibila","commit_stats":{"total_commits":43,"total_committers":3,"mean_commits":"14.333333333333334","dds":0.5348837209302326,"last_synced_commit":"e478df1cb28a3a0c45973f19bcec0c7828a479e4"},"previous_names":["jndiogo/sibila"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/jndiogo/sibila","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jndiogo%2Fsibila","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jndiogo%2Fsibila/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jndiogo%2Fsibila/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jndiogo%2Fsibila/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jndiogo","download_url":"https://codeload.github.com/jndiogo/sibila/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jndiogo%2Fsibila/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260162221,"owners_count":22968005,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","dataclasses","gguf","gpt","large-language-models","llamacpp","llm-inference","local-ai","local-models","openai","pydantic","python","structured-data","structured-extraction","structured-generation"],"created_at":"2024-09-24T13:33:47.135Z","updated_at":"2025-06-16T12:32:43.885Z","avatar_url":"https://github.com/jndiogo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sibila\n\nExtract structured data from remote or local LLM models. Predictable output is important for serious use of LLMs.\n\n- Query structured data into Pydantic objects, dataclasses or simple types.\n- Access remote models from OpenAI, Anthropic, Mistral AI and other providers.\n- Use vision models like GPT-4o, to extract structured data from images.\n- Run local models like Llama-3, Phi-3, OpenChat or any other GGUF file model.\n- Sibila is also a general purpose model access library, to generate plain text or free JSON results, with the same API for local and remote models.\n\nNo matter how well you craft a prompt begging a model for the format you need, it can always respond something else. Extracting structured data can be a big step into getting predictable behavior from your models.\n\nSee [What can you do with Sibila?](https://jndiogo.github.io/sibila/what/)\n\n\n## Structured data\n\nTo extract structured data, using a local model:\n\n``` python\nfrom sibila import Models\nfrom pydantic import BaseModel\n\nclass Info(BaseModel):\n    event_year: int\n    first_name: str\n    last_name: str\n    age_at_the_time: int\n    nationality: str\n\nmodel = Models.create(\"llamacpp:openchat\")\n\nmodel.extract(Info, \"Who was the first man in the moon?\")\n```\n\nReturns an instance of class Info, created from the model's output:\n\n``` python\nInfo(event_year=1969,\n     first_name='Neil',\n     last_name='Armstrong',\n     age_at_the_time=38,\n     nationality='American')\n```\n\nOr to use a remote model like OpenAI's GPT-4, we would simply replace the model's name:\n\n``` python\nmodel = Models.create(\"openai:gpt-4\")\n\nmodel.extract(Info, \"Who was the first man in the moon?\")\n```\n\nIf Pydantic BaseModel objects are too much for your project, Sibila supports similar functionality with Python dataclasses. Also includes asynchronous access to remote models.\n\n\n## Vision models\n\nSibila supports image input, alongside text prompts. For example, to extract the fields from a receipt in a photo:\n\n![Image](https://upload.wikimedia.org/wikipedia/commons/6/6a/Receipts_in_Italy_13.jpg)\n\n``` python\nfrom pydantic import Field\n\nmodel = Models.create(\"openai:gpt-4o\")\n\nclass ReceiptLine(BaseModel):\n    \"\"\"Receipt line data\"\"\"\n    description: str\n    cost: float\n\nclass Receipt(BaseModel):\n    \"\"\"Receipt information\"\"\"\n    total: float = Field(description=\"Total value\")\n    lines: list[ReceiptLine] = Field(description=\"List of lines of paid items\")\n\ninfo = model.extract(Receipt,\n                     (\"Extract receipt information.\", \n                      \"https://upload.wikimedia.org/wikipedia/commons/6/6a/Receipts_in_Italy_13.jpg\"))\ninfo\n```\n\nReturns receipt fields structured in a Pydantic object:\n\n```\nReceipt(total=5.88, \n        lines=[ReceiptLine(description='BIS BORSE TERM.S', cost=3.9), \n               ReceiptLine(description='GHIACCIO 2X400 G', cost=0.99),\n               ReceiptLine(description='GHIACCIO 2X400 G', cost=0.99)])\n```\n\n\nAnother example - extracting the most import elements in a photo:\n\n![Image](https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Hohenloher_Freilandmuseum_-_Baugruppe_Hohenloher_Dorf_-_Bauerngarten_-_Ansicht_von_Osten_im_Juni.jpg/640px-Hohenloher_Freilandmuseum_-_Baugruppe_Hohenloher_Dorf_-_Bauerngarten_-_Ansicht_von_Osten_im_Juni.jpg)\n\n``` python\nphoto = \"https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Hohenloher_Freilandmuseum_-_Baugruppe_Hohenloher_Dorf_-_Bauerngarten_-_Ansicht_von_Osten_im_Juni.jpg/640px-Hohenloher_Freilandmuseum_-_Baugruppe_Hohenloher_Dorf_-_Bauerngarten_-_Ansicht_von_Osten_im_Juni.jpg\"\n\nmodel.extract(list[str],\n              (\"Extract up to five of the most important elements in this photo.\",\n              photo))\n```\n\nReturns a list with the five strings:\n\n```\n['House with red roof and beige walls',\n 'Large tree with green leaves',\n 'Garden with various plants and flowers',\n 'Clear blue sky',\n 'Wooden fence']\n```\n\n\nLocal vision models based on llama.cpp/llava can also be used.\n\n⭐ Like our work? [Give us a star!](https://github.com/jndiogo/sibila)\n\n\n## Docs\n\n[The docs explain](https://jndiogo.github.io/sibila/) the main concepts, include examples and an API reference.\n\n\n## Installation\n\nSibila can be installed from PyPI by doing:\n\n```\npip install -U sibila\n```\n\nSee [Getting started](https://jndiogo.github.io/sibila/installing/) for more information.\n\n\n\n## Examples\n\nThe [Examples](https://jndiogo.github.io/sibila/examples/) show what you can do with local or remote models in Sibila: structured data extraction, classification, summarization, etc.\n\n\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/jndiogo/sibila/blob/main/LICENSE) file for details.\n\n\n## Acknowledgements\n\nSibila wouldn't be be possible without the help of great software and people:\n\n- [llama.cpp](https://github.com/ggerganov/llama.cpp)\n- [llama-cpp-python](https://github.com/abetlen/llama-cpp-python)\n- [Hugging Face model hub](https://huggingface.co/) and [TheBloke (Tom Jobbins)](https://huggingface.co/TheBloke)\n\nThank you!\n\n\n## Sibila?\n\nSibila is the Portuguese word for Sibyl. [The Sibyls](https://en.wikipedia.org/wiki/Sibyl) were wise oracular women in ancient Greece. Their mysterious words puzzled people throughout the centuries, providing insight or prophetic predictions, \"uttering things not to be laughed at\".\n\n![Michelangelo's Delphic Sibyl, Sistine Chapel ceiling](https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/DelphicSibylByMichelangelo.jpg/471px-DelphicSibylByMichelangelo.jpg)\n\nMichelangelo's Delphic Sibyl, in the Sistine Chapel ceiling.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjndiogo%2Fsibila","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjndiogo%2Fsibila","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjndiogo%2Fsibila/lists"}