{"data":{"slug":"r2d4-rellm","name":"rellm","tagline":"Exact structure out of any language model completion","github_url":"https://github.com/r2d4/rellm","owner":"r2d4","repo":"rellm","owner_avatar_url":"https://avatars.githubusercontent.com/u/896032?v=4","primary_language":"Python","stars":511,"forks":24,"topics":["huggingface-transformers","llm","transformers"],"archived":false,"github_pushed_at":"2023-08-10T19:42:58+00:00","maintenance_label":"Dormant","stars_delta_30d":-2,"url":"https://www.graphcanon.com/tools/r2d4-rellm","markdown_url":"https://www.graphcanon.com/tools/r2d4-rellm.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/r2d4-rellm","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=r2d4-rellm","description":"Exact structure out of any language model completion.","homepage_url":null,"license":"MIT","open_issues":5,"watchers":9,"ai_summary":"rellm is a tool that ensures structured outputs from language model completions using the Hugging Face Transformers library.","readme_excerpt":"### Installation\n```\npip install rellm\n```\n\nThe preliminary results are interesting -- even for small models, constraining the token space with ReLLM can improve the quality of the completions. Not to mention the ability to more easily parse the output programmatically. Take a look at some of the [examples](examples). For an example of parsing a context-free grammar (like JSON) with ReLLM, see [r2d4/parserllm](https://github.com/r2d4/parserllm).\n\n```python\nimport regex\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\nfrom rellm import complete_re\n\nmodel = AutoModelForCausalLM.from_pretrained(\"gpt2\")\ntokenizer = AutoTokenizer.from_pretrained(\"gpt2\")\n\nprompt = \"ReLLM, the best way to get structured data out of LLMs, is an acronym for \"\npattern = regex.compile(r'Re[a-z]+ L[a-z]+ L[a-z]+ M[a-z]+')\noutput = complete_re(tokenizer=tokenizer, \n                     model=model, \n                     prompt=prompt,\n                     pattern=pattern,\n                     do_sample=True,\n                     max_new_tokens=80)\nprint(output)\n```\n\n```\n> Realized Logistic Logistics Model\n```","github_created_at":"2023-05-05T03:51:56+00:00","created_at":"2026-07-11T10:54:13.158579+00:00","updated_at":"2026-09-20T05:32:23.365854+00:00","categories":[{"slug":"llm-frameworks","name":"LLM Frameworks","url":"https://www.graphcanon.com/categories/llm-frameworks","markdown_url":"https://www.graphcanon.com/categories/llm-frameworks.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/llm-frameworks"},{"slug":"model-training","name":"Model Training","url":"https://www.graphcanon.com/categories/model-training","markdown_url":"https://www.graphcanon.com/categories/model-training.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/model-training"}],"tags":[{"slug":"huggingface-transformers","name":"huggingface-transformers"},{"slug":"llm","name":"llm"},{"slug":"transformers","name":"transformers"}],"trust":{"provenance":{"is_fork":false,"github_id":636529302,"owner_type":"User","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-08-15T18:01:07.064Z","maintenance":{"label":"Dormant","score":18,"methodology":"github_public_v1","releases_90d":0,"days_since_push":1100,"last_release_at":"2023-05-06T01:56:01Z","stars_delta_30d":-2,"open_issues_delta_30d":0},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-11T10:54:14.491Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-08-15T18:01:07.537Z"},"languages":{"value":["python"],"source":"github.language+pyproject.toml","observed_at":"2026-08-15T18:01:07.537Z"},"license_spdx":{"value":"MIT","source":"github.license","observed_at":"2026-08-15T18:01:07.537Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":null,"constraints":null,"when_to_use":["- When you require precise and exact structure in output data generated from any language model, utilizing rellm can ensure consistency.","- If your application needs to process text through Hugging Face's models and demands that outputs strictly adhere to specific formats, rellm is ideal."],"when_not_to_use":["- Avoid using rellm if you are not working with the Hugging Face Transformers library or do not need structured output formats.","- If your project can tolerate some level of unstructured or less rigidly formatted outputs from language models, other solutions might be more appropriate."],"source":"enrich:decision_facts","observed_at":"2026-07-12T07:05:29.013Z"},"constraint_facets":null,"decision_summary":[{"label":"Adopt for","value":"rellm is a Python tool that guarantees structured outputs from language model completions by leveraging the Hugging Face Transformers library."}]}}