Two interfaces cover work that should run on this machine. Both follow the embedder’s pattern: a small engine protocol so tests need no model file, a lazy import of the heavy library, one lock because the engines are not thread-safe, and a fake for tests.
A local LLM client
LiteRtLlmClient is an LlmClient over a LiteRT-LM model, such as Gemma 4 E2B as a .litertlm file. It takes the same complete and acomplete calls as the ADK client, so the Translator, and anything else that depends on LlmClient, runs on it unchanged.
from ladygraph.llm import LiteRtLlmClient, LlmConfig, Translatorfrom ladygraph.llm.adk import create_clientllm = LiteRtLlmClient("model/gemma-4-E2B-it-gpu.litertlm", device="gpu") # or: create_client(LlmConfig(backend="litert", model=..., device="gpu"))print(Translator(llm).translate("Chi vượt 10% định mức cần Tổng Giám đốc phê duyệt.").text)
Structured output is constrained decoding. The pydantic schema goes to the engine, which can only emit JSON that matches it. Without that, the model answered in a fence with its own key names, which no repair step fixes. If an engine refuses a schema, the client falls back to an instruction plus the same validate-and-repair step the other backends use, and logs it once. Either way the answer is validated against the pydantic class.
Reproducible. Greedy sampling (top-k 1, temperature 0, a fixed seed) gave the same answer on repeated calls.
Stateless and serialized. Each call is a fresh conversation, so a prompt carries its own context. One lock serializes calls.
Plain text.complete_text(system, prompt) returns text with no JSON wrapper. The aligned translator and the back-quote step use it.
Configuration: LlmConfig(backend="litert", model=<path to the .litertlm>, device="cpu"|"gpu"|"npu", max_output_tokens, thinking, repair_attempts).
Choose the device
LITERT_LLM_DEVICE (or device=) picks the backend: cpu (the default), gpu or npu. A .litertlm file is built for one backend, so a file built for the GPU on cpu can fail with:
tf_lite_prefill_decode not found in the model
Set the device to the one the file was built for, or use a model built for the CPU. In the repository’s model/ folder, gemma-4-E2B-it-gpu.litertlm is a GPU build and gemma3-1b-it-int4.litertlm is a smaller model.
Speed
Measured on a Mac with Gemma 4 E2B on the GPU: loading plus the first call took about 12 s. Three Vietnamese-to-English sentences then took 5.7, 7.7 and 11 s through the Translator with the packaged glossary, all passing the gate on the first attempt. Extracting concepts from one short passage took 12 to 16 s. It is a local and private path, not a fast one.
Only this one model on the GPU was tried. npu and the thinking setting are untested. Token counts are not reported in LlmUsage. The packaged translator prompt carries the whole glossary, which is part of why a sentence takes seconds.
A span tagger
An LLM extractor asks a model for concepts and quotes. A tagger finds spans of text and labels them, with a score, in one small model run. SpanTagger is the interface for building extractors on that.
tagger.recognize(texts, labels, threshold=0.5, flat=True)# one list of Span(start, end, text, label, score) per text, or None for a text it cannot take
Piece
What it does
SpanTagger, Span
The protocol and the result. Offsets are into the text as passed. Pass faithful(passage.text) to get positions in the coordinates evidence uses.
recognize_all
A tagger carries labels_per_call labels at most. This splits any number of labels into calls and merges the spans.
recognize_windowed
For text longer than the tagger can take: overlapping word windows, and a window that does not fit is halved. Spans come back in the full text’s offsets.
merge_spans
Spans without clashes from several lists: the best score wins, with the same rules as the model’s decoder.
spans_to_candidates
Spans to candidate dicts (word, type, description, quote) through a label-to-type map.
FakeSpanTagger
For tests.
ner.litert_gliner.LiteRtGliner
GLiNER (zero-shot: any labels you name) as a LiteRT .tflite, on the CPU or GPU.
ner.tokenizers_encoder.TokenizersEncoder
GLiNER’s tokenization and collation without PyTorch. LiteRtGliner uses it by default.
from ladygraph.core.normalize import faithfulfrom ladygraph.ner import recognize_windowed, spans_to_candidatesfrom ladygraph.ner.litert_gliner import LiteRtGlinertagger = LiteRtGliner("model/tflite/gliner_gpu.tflite", tokenizer="gliner-community/gliner_small-v2.5", device="gpu")text = faithful(passage.text)spans = recognize_windowed(tagger, text, ["organization", "date", "percentage"], size=8)candidates = spans_to_candidates(spans, {"organization": "Body", "percentage": "Rule"}, min_score=0.5)# ground each candidate's quote in the passage with locate_quote, then assemble and validate the Contribution
To use a tagger in a project, set extractor.kind: ner as described on Extractors.
What the converted model does
These facts are from gliner_small-v2.5 on the GPU.
Fixed shapes. The .tflite takes a batch of 2 texts, 28 subwords, 15 words and 5 label slots. A 13-word sentence with numbers already did not fit, so real text needs recognize_windowed. The adapter returns None for a text that does not fit, and answers an empty text with [].
Fast. Six short texts against seven labels (two calls) took 134 ms. Two long sentences took 24 and 41 ms, windowed. The PyTorch model took about 1.7 s per chunk in the experiment.
Matches the reference. On six sentences its entities were identical to GLiNER.inference, and the offsets were exact.
Float32 on the GPU. The DeBERTa encoder overflows in float16, so the adapter forces float32.
Loads in about 8 s, with no PyTorch. Importing the gliner package would add torch (about 14 s) and weights the .tflite makes unnecessary (about 8 s). TokenizersEncoder does the same preparation with the tokenizers library. What remains is compiling the .tflite for the GPU, about 8 s, which is not cached between processes. encoder_kind="gliner" forces the package, and "auto" falls back to it if the checkpoint lacks tokenizer.json or gliner_config.json.
The same inputs as GLiNER. On 95 texts and 4 label sets, including Vietnamese, CJK and Arabic, all 1,152 arrays matched: token ids, attention and word masks, spans, and the character maps. One difference between files: the checkpoint’s tokenizer.json normalizes with NFKC, while GLiNER’s own tokenizer uses NFC, so the encoder sets GLiNER’s normalizer. Only the whitespace splitter and the span model are supported. Anything else raises, and auto falls back.
Generic labels give a weak signal. Percentages were reliable (“200%” at 0.94). “Ceiling” came out as a rating level (0.43) and “KHUT” as money (0.57). The labels you choose matter more than the runtime.
English only.gliner_small-v2.5 is an English checkpoint. Vietnamese text needs a multilingual checkpoint, or translation first. See Translation and verification.
One bug from the original experiment is fixed here. GLiNER’s prepare_batch silently drops empty texts, so an empty string in a batch shifted every later result onto the wrong text. The adapter answers empty texts itself and checks the map GLiNER returns.Converting a checkpoint to .tflite is outside this package. The conversion scripts are in demoGraphIndex/prep/prepare_gliner/convert.
Tests that use real files
The tests that need the real files skip themselves unless you name them. Set LITERT_LLM_MODEL and LITERT_LLM_DEVICE for tests/test_litert_llm.py, and GLINER_TFLITE, GLINER_TOKENIZER and GLINER_DEVICE for tests/test_ner.py. See Environment variables.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"ladyGraph","colors":{"primary":"#B1212D","light":"#FFB3B0","dark":"#D43C42"},"logo":{"light":"https://mintcdn.com/daves-tran/-ttQYAEZXt81_rL8/logo/light.svg?fit=max\u0026auto=format\u0026n=-ttQYAEZXt81_rL8\u0026q=85\u0026s=9a4569643e4737486485cedb27379a5e","dark":"https://mintcdn.com/daves-tran/-ttQYAEZXt81_rL8/logo/dark.svg?fit=max\u0026auto=format\u0026n=-ttQYAEZXt81_rL8\u0026q=85\u0026s=0f2023129a8a49436037f6057e5f038e"},"favicon":{"light":"https://mintcdn.com/daves-tran/-ttQYAEZXt81_rL8/favicon.svg?fit=max\u0026auto=format\u0026n=-ttQYAEZXt81_rL8\u0026q=85\u0026s=83bdf2392fd8958170cffb7ae2e87ce8","dark":"https://mintcdn.com/daves-tran/-ttQYAEZXt81_rL8/favicon-dark.svg?fit=max\u0026auto=format\u0026n=-ttQYAEZXt81_rL8\u0026q=85\u0026s=d3d4980fac75b919dcf0d003cfc995f3"},"background":{"color":{"light":"#F8F9FF","dark":"#0D1420"}},"navbar":{"links":[{"href":"https://github.com/DTJ-Tran/ladyGraph","type":"github"}]},"footer":{"socials":{"github":"https://github.com/DTJ-Tran/ladyGraph"}},"fonts":{"heading":{"family":"Inter","weight":700},"body":{"family":"Inter","weight":400}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":false},"navigation":{"languages":[{"language":"en","default":true,"href":""},{"language":"vi","href":"vi"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"daves-tran","hasAudioNarration":false,"actualSubdomain":"daves-tran","customDomains":["ladygraph.io.vn"],"gitSource":{"type":"github","owner":"dtj-tran","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":"","_id":"6b12caeddb79db5958a488b8"},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6b15890d0cc8674c3fb86d74","clientVersion":"0.0.4458","searchFilterCounts":[{"language":"en","tag":"API reference","count":13},{"language":"vi","tag":"Tham chiếu API","count":13},{"language":"en","tag":"Concepts","count":11},{"language":"vi","tag":"Khái niệm","count":11},{"language":"en","tag":"Guides","count":10},{"language":"vi","tag":"Hướng dẫn","count":10},{"language":"en","tag":"Get started","count":2},{"language":"vi","tag":"Bắt đầu","count":2},{"language":"en","tag":"Reference","count":1},{"language":"vi","tag":"Tham chiếu","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"guides/local-models","slug":"/guides/local-models","pageMetadata":{"title":"Local models","description":"Run an LLM and a span tagger on your own machine.","href":"/guides/local-models"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Run an LLM and a span tagger on your own machine.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Two interfaces cover work that should run on this machine. Both follow the embedder’s pattern: a small engine protocol so tests need no model file, a lazy import of the heavy library, one lock because the engines are not thread-safe, and a fake for tests.`}),`\n`,_jsx(Heading,{level:`2`,id:`a-local-llm-client`,children:`A local LLM client`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`LiteRtLlmClient`}),` is an `,_jsx(_components.code,{children:`LlmClient`}),` over a LiteRT-LM model, such as Gemma 4 E2B as a `,_jsx(_components.code,{children:`.litertlm`}),` file. It takes the same `,_jsx(_components.code,{children:`complete`}),` and `,_jsx(_components.code,{children:`acomplete`}),` calls as the ADK client, so the `,_jsx(_components.code,{children:`Translator`}),`, and anything else that depends on `,_jsx(_components.code,{children:`LlmClient`}),`, runs on it unchanged.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ladygraph.llm `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` LiteRtLlmClient, LlmConfig, Translator`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ladygraph.llm.adk `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` create_client`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`llm `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` LiteRtLlmClient(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"model/gemma-4-E2B-it-gpu.litertlm\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`device`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpu\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# or: create_client(LlmConfig(backend=\"litert\", model=..., device=\"gpu\"))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(Translator(llm).translate(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Chi vượt 10% định mức cần Tổng Giám đốc phê duyệt.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`).text)`})]}),`\n`]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Structured output is constrained decoding.`}),` The pydantic schema goes to the engine, which can only emit JSON that matches it. Without that, the model answered in a fence with its own key names, which no repair step fixes. If an engine refuses a schema, the client falls back to an instruction plus the same validate-and-repair step the other backends use, and logs it once. Either way the answer is validated against the pydantic class.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Reproducible.`}),` Greedy sampling (top-k 1, temperature 0, a fixed seed) gave the same answer on repeated calls.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Stateless and serialized.`}),` Each call is a fresh conversation, so a prompt carries its own context. One lock serializes calls.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Plain text.`}),` `,_jsx(_components.code,{children:`complete_text(system, prompt)`}),` returns text with no JSON wrapper. The aligned translator and the back-quote step use it.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Configuration: `,_jsx(_components.code,{children:`LlmConfig(backend=\"litert\", model=\u003cpath to the .litertlm>, device=\"cpu\"|\"gpu\"|\"npu\", max_output_tokens, thinking, repair_attempts)`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`choose-the-device`,children:`Choose the device`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`LITERT_LLM_DEVICE`}),` (or `,_jsx(_components.code,{children:`device=`}),`) picks the backend: `,_jsx(_components.code,{children:`cpu`}),` (the default), `,_jsx(_components.code,{children:`gpu`}),` or `,_jsx(_components.code,{children:`npu`}),`. A `,_jsx(_components.code,{children:`.litertlm`}),` file is built for one backend, so a file built for the GPU on `,_jsx(_components.code,{children:`cpu`}),` can fail with:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`tf_lite_prefill_decode not found in the model`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`Set the device to the one the file was built for, or use a model built for the CPU. In the repository’s `,_jsx(_components.code,{children:`model/`}),` folder, `,_jsx(_components.code,{children:`gemma-4-E2B-it-gpu.litertlm`}),` is a GPU build and `,_jsx(_components.code,{children:`gemma3-1b-it-int4.litertlm`}),` is a smaller model.`]}),`\n`,_jsx(Heading,{level:`3`,id:`speed`,children:`Speed`}),`\n`,_jsxs(_components.p,{children:[`Measured on a Mac with Gemma 4 E2B on the GPU: loading plus the first call took about 12 s. Three Vietnamese-to-English sentences then took 5.7, 7.7 and 11 s through the `,_jsx(_components.code,{children:`Translator`}),` with the packaged glossary, all passing the gate on the first attempt. Extracting concepts from one short passage took 12 to 16 s. It is a local and private path, not a fast one.`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Only this one model on the GPU was tried. `,_jsx(_components.code,{children:`npu`}),` and the `,_jsx(_components.code,{children:`thinking`}),` setting are untested. Token counts are not reported in `,_jsx(_components.code,{children:`LlmUsage`}),`. The packaged translator prompt carries the whole glossary, which is part of why a sentence takes seconds.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`a-span-tagger`,children:`A span tagger`}),`\n`,_jsxs(_components.p,{children:[`An LLM extractor asks a model for concepts and quotes. A tagger finds spans of text and labels them, with a score, in one small model run. `,_jsx(_components.code,{children:`SpanTagger`}),` is the interface for building extractors on that.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`tagger.recognize(texts, labels, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`threshold`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`flat`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# one list of Span(start, end, text, label, score) per text, or None for a text it cannot take`})}),`\n`]})})}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Piece`}),_jsx(_components.th,{children:`What it does`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`SpanTagger`}),`, `,_jsx(_components.code,{children:`Span`})]}),_jsxs(_components.td,{children:[`The protocol and the result. Offsets are into the text as passed. Pass `,_jsx(_components.code,{children:`faithful(passage.text)`}),` to get positions in the coordinates evidence uses.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`recognize_all`})}),_jsxs(_components.td,{children:[`A tagger carries `,_jsx(_components.code,{children:`labels_per_call`}),` labels at most. This splits any number of labels into calls and merges the spans.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`recognize_windowed`})}),_jsx(_components.td,{children:`For text longer than the tagger can take: overlapping word windows, and a window that does not fit is halved. Spans come back in the full text’s offsets.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`merge_spans`})}),_jsx(_components.td,{children:`Spans without clashes from several lists: the best score wins, with the same rules as the model’s decoder.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`spans_to_candidates`})}),_jsx(_components.td,{children:`Spans to candidate dicts (word, type, description, quote) through a label-to-type map.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`FakeSpanTagger`})}),_jsx(_components.td,{children:`For tests.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`ner.litert_gliner.LiteRtGliner`})}),_jsxs(_components.td,{children:[`GLiNER (zero-shot: any labels you name) as a LiteRT `,_jsx(_components.code,{children:`.tflite`}),`, on the CPU or GPU.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`ner.tokenizers_encoder.TokenizersEncoder`})}),_jsxs(_components.td,{children:[`GLiNER’s tokenization and collation without PyTorch. `,_jsx(_components.code,{children:`LiteRtGliner`}),` uses it by default.`]})]})]})]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ladygraph.core.normalize `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` faithful`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ladygraph.ner `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` recognize_windowed, spans_to_candidates`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ladygraph.ner.litert_gliner `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` LiteRtGliner`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`tagger `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` LiteRtGliner(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"model/tflite/gliner_gpu.tflite\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`tokenizer`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gliner-community/gliner_small-v2.5\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`device`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpu\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`text `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` faithful(passage.text)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`spans `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` recognize_windowed(tagger, text, [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"organization\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"date\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"percentage\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`], `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`size`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`8`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`candidates `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` spans_to_candidates(spans, {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"organization\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Body\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"percentage\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Rule\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`min_score`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# ground each candidate's quote in the passage with locate_quote, then assemble and validate the Contribution`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`To use a tagger in a project, set `,_jsx(_components.code,{children:`extractor.kind: ner`}),` as described on `,_jsx(_components.a,{href:`/guides/extractors`,children:`Extractors`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`what-the-converted-model-does`,children:`What the converted model does`}),`\n`,_jsxs(_components.p,{children:[`These facts are from `,_jsx(_components.code,{children:`gliner_small-v2.5`}),` on the GPU.`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Fixed shapes.`}),` The `,_jsx(_components.code,{children:`.tflite`}),` takes a batch of 2 texts, 28 subwords, 15 words and 5 label slots. A 13-word sentence with numbers already did not fit, so real text needs `,_jsx(_components.code,{children:`recognize_windowed`}),`. The adapter returns `,_jsx(_components.code,{children:`None`}),` for a text that does not fit, and answers an empty text with `,_jsx(_components.code,{children:`[]`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Fast.`}),` Six short texts against seven labels (two calls) took 134 ms. Two long sentences took 24 and 41 ms, windowed. The PyTorch model took about 1.7 s per chunk in the experiment.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Matches the reference.`}),` On six sentences its entities were identical to `,_jsx(_components.code,{children:`GLiNER.inference`}),`, and the offsets were exact.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Float32 on the GPU.`}),` The DeBERTa encoder overflows in float16, so the adapter forces float32.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Loads in about 8 s, with no PyTorch.`}),` Importing the `,_jsx(_components.code,{children:`gliner`}),` package would add torch (about 14 s) and weights the `,_jsx(_components.code,{children:`.tflite`}),` makes unnecessary (about 8 s). `,_jsx(_components.code,{children:`TokenizersEncoder`}),` does the same preparation with the `,_jsx(_components.code,{children:`tokenizers`}),` library. What remains is compiling the `,_jsx(_components.code,{children:`.tflite`}),` for the GPU, about 8 s, which is not cached between processes. `,_jsx(_components.code,{children:`encoder_kind=\"gliner\"`}),` forces the package, and `,_jsx(_components.code,{children:`\"auto\"`}),` falls back to it if the checkpoint lacks `,_jsx(_components.code,{children:`tokenizer.json`}),` or `,_jsx(_components.code,{children:`gliner_config.json`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`The same inputs as GLiNER.`}),` On 95 texts and 4 label sets, including Vietnamese, CJK and Arabic, all 1,152 arrays matched: token ids, attention and word masks, spans, and the character maps. One difference between files: the checkpoint’s `,_jsx(_components.code,{children:`tokenizer.json`}),` normalizes with NFKC, while GLiNER’s own tokenizer uses NFC, so the encoder sets GLiNER’s normalizer. Only the whitespace splitter and the span model are supported. Anything else raises, and `,_jsx(_components.code,{children:`auto`}),` falls back.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Generic labels give a weak signal.`}),` Percentages were reliable (“200%” at 0.94). “Ceiling” came out as a rating level (0.43) and “KHUT” as money (0.57). The labels you choose matter more than the runtime.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`English only.`}),` `,_jsx(_components.code,{children:`gliner_small-v2.5`}),` is an English checkpoint. Vietnamese text needs a multilingual checkpoint, or translation first. See `,_jsx(_components.a,{href:`/guides/translation`,children:`Translation and verification`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`One bug from the original experiment is fixed here. GLiNER’s `,_jsx(_components.code,{children:`prepare_batch`}),` silently drops empty texts, so an empty string in a batch shifted every later result onto the wrong text. The adapter answers empty texts itself and checks the map GLiNER returns.`]}),`\n`,_jsxs(_components.p,{children:[`Converting a checkpoint to `,_jsx(_components.code,{children:`.tflite`}),` is outside this package. The conversion scripts are in `,_jsx(_components.code,{children:`demoGraphIndex/prep/prepare_gliner/convert`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`tests-that-use-real-files`,children:`Tests that use real files`}),`\n`,_jsxs(_components.p,{children:[`The tests that need the real files skip themselves unless you name them. Set `,_jsx(_components.code,{children:`LITERT_LLM_MODEL`}),` and `,_jsx(_components.code,{children:`LITERT_LLM_DEVICE`}),` for `,_jsx(_components.code,{children:`tests/test_litert_llm.py`}),`, and `,_jsx(_components.code,{children:`GLINER_TFLITE`}),`, `,_jsx(_components.code,{children:`GLINER_TOKENIZER`}),` and `,_jsx(_components.code,{children:`GLINER_DEVICE`}),` for `,_jsx(_components.code,{children:`tests/test_ner.py`}),`. See `,_jsx(_components.a,{href:`/reference/environment-variables`,children:`Environment variables`}),`.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Local models","description":"Run an LLM and a span tagger on your own machine.","href":"/guides/local-models"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"A local LLM client","slug":"a-local-llm-client","depth":2,"children":[{"title":"Choose the device","slug":"choose-the-device","depth":3,"children":[]},{"title":"Speed","slug":"speed","depth":3,"children":[]}]},{"title":"A span tagger","slug":"a-span-tagger","depth":2,"children":[{"title":"What the converted model does","slug":"what-the-converted-model-does","depth":3,"children":[]}]},{"title":"Tests that use real files","slug":"tests-that-use-real-files","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"daves-tran","siteName":"ladyGraph","title":"Local models - ladyGraph","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"en":{"href":"/guides/local-models","matchLevel":0},"vi":{"href":"/vi/guides/local-models","matchLevel":1}}},"lastModified":"2026-12-06T14:10:55.752Z","originalFileLocation":"guides/local-models.mdx","locale":"en"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Run an LLM and a span tagger on your own machine.\">\u003cmeta data-mint-head name=\"application-name\" content=\"ladyGraph\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Local models - ladyGraph\">\u003cmeta data-mint-head property=\"og:description\" content=\"Run an LLM and a span tagger on your own machine.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"ladyGraph\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://ladygraph.io.vn/guides/local-models\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://daves-tran.mintlify.site/_mintlify/api/og/v2?division=Guides\u0026amp;title=Local+models\u0026amp;description=Run+an+LLM+and+a+span+tagger+on+your+own+machine.\u0026amp;theme=69b40a9290c082c10989a3c4\u0026amp;signature=88618d166de3a00ee1de2e86c10df5125990d0ddb02a978b7dd09eee2d4ddb3f\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Local models - ladyGraph\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Run an LLM and a span tagger on your own machine.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://daves-tran.mintlify.site/_mintlify/api/og/v2?division=Guides\u0026amp;title=Local+models\u0026amp;description=Run+an+LLM+and+a+span+tagger+on+your+own+machine.\u0026amp;theme=69b40a9290c082c10989a3c4\u0026amp;signature=88618d166de3a00ee1de2e86c10df5125990d0ddb02a978b7dd09eee2d4ddb3f\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/daves-tran/1ye87DRAFs_MIUAC/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"ladyGraph\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#B1212D\">\u003clink data-mint-head rel=\"canonical\" href=\"https://ladygraph.io.vn/guides/local-models\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/guides/local-models.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://ladygraph.io.vn/guides/local-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"vi\" href=\"https://ladygraph.io.vn/vi/guides/local-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://ladygraph.io.vn/guides/local-models\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://ladygraph.io.vn/#organization\",\"name\":\"ladyGraph\",\"url\":\"https://ladygraph.io.vn\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/daves-tran/-ttQYAEZXt81_rL8/logo/light.svg?fit=max\u0026auto=format\u0026n=-ttQYAEZXt81_rL8\u0026q=85\u0026s=9a4569643e4737486485cedb27379a5e\"}},{\"@type\":\"WebSite\",\"@id\":\"https://ladygraph.io.vn#website\",\"name\":\"ladyGraph\",\"url\":\"https://ladygraph.io.vn\",\"publisher\":{\"@id\":\"https://ladygraph.io.vn/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://ladygraph.io.vn/guides/local-models#webpage\",\"url\":\"https://ladygraph.io.vn/guides/local-models\",\"name\":\"Local models\",\"description\":\"Run an LLM and a span tagger on your own machine.\",\"dateModified\":\"2026-12-06T14:10:55.752Z\",\"isPartOf\":{\"@id\":\"https://ladygraph.io.vn#website\"},\"breadcrumb\":{\"@id\":\"https://ladygraph.io.vn/guides/local-models#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://ladygraph.io.vn/guides/local-models#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Guides\",\"item\":\"https://ladygraph.io.vn/guides/tutorials\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Local models\",\"item\":\"https://ladygraph.io.vn/guides/local-models\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://ladygraph.io.vn/guides/local-models#article\",\"headline\":\"Local models\",\"name\":\"Local models\",\"description\":\"Run an LLM and a span tagger on your own machine.\",\"url\":\"https://ladygraph.io.vn/guides/local-models\",\"mainEntityOfPage\":{\"@id\":\"https://ladygraph.io.vn/guides/local-models#webpage\"},\"dateModified\":\"2026-12-06T14:10:55.752Z\",\"publisher\":{\"@id\":\"https://ladygraph.io.vn/#organization\"},\"isPartOf\":{\"@id\":\"https://ladygraph.io.vn#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"ladyGraph\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"ladyGraph\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/guides/local-models.md","siteName":"ladyGraph","nav":{"global":null,"languages":[{"language":"en","default":true,"groups":[{"group":"Get started","pages":[{"title":"Introduction","href":""},{"title":"Quickstart","href":"/quickstart"}]},{"group":"Concepts","pages":[{"title":"How it works","href":"/concepts/how-it-works"},{"title":"Vocabulary","href":"/concepts/vocabulary"},{"title":"Architecture","href":"/concepts/architecture"},{"title":"Data model","href":"/concepts/data-model"},{"title":"Addresses, ids and fingerprints","href":"/concepts/addresses-and-fingerprints"},{"title":"Context tree and concept graph","href":"/concepts/context-tree"},{"title":"Ownership, versions and merging","href":"/concepts/ownership-and-merging"},{"title":"Search in depth","href":"/concepts/search-in-depth"},{"title":"Storage","href":"/concepts/storage"},{"title":"Invariants","href":"/concepts/invariants"},{"title":"Status and known limits","href":"/concepts/status-and-limits"}]},{"group":"Guides","pages":[{"title":"Tutorials","href":"/guides/tutorials"},{"title":"Configure a project","href":"/guides/configure-a-project"},{"title":"Sources","href":"/guides/sources"},{"title":"Extractors","href":"/guides/extractors"},{"title":"Prompt and glossary","href":"/guides/prompt-and-glossary"},{"title":"Translation and verification","description":"Translate with positions, escalate to a stronger model, and check the result.","href":"/guides/translation"},{"title":"Local models","href":"/guides/local-models"},{"title":"Entity kinds","description":"Name the codes and abbreviations in your documents, and turn them into concepts.","href":"/guides/entity-kinds"},{"title":"Term-list builder","href":"/guides/term-list-builder"},{"title":"Flight server","href":"/guides/flight-server"}]},{"group":"Reference","pages":[{"title":"Environment variables","href":"/reference/environment-variables"}]},{"group":"API reference","pages":[{"title":"Interfaces","href":"/reference/api/overview"},{"title":"core","href":"/reference/api/core"},{"title":"sources","href":"/reference/api/sources"},{"title":"extractors","href":"/reference/api/extractors"},{"title":"llm","href":"/reference/api/llm"},{"title":"embedding","href":"/reference/api/embedding"},{"title":"decision","href":"/reference/api/decision"},{"title":"retrieval","href":"/reference/api/retrieval"},{"title":"stores","href":"/reference/api/stores"},{"title":"translation","href":"/reference/api/translation"},{"title":"ner","href":"/reference/api/ner"},{"title":"chunking","href":"/reference/api/chunking"},{"title":"authoring","href":"/reference/api/authoring"}]}]},{"language":"vi","pages":[{"title":"vi","href":"/vi/guides/local-models"}]}]},"basePath":"","title":"Local models - ladyGraph","deploymentId":"dpl_HZVV42MMRSo9WnNHfTGZvby5jph9","buildId":"dpl_HZVV42MMRSo9WnNHfTGZvby5jph9","dynamics":[],"chunks":[]}