Text Generation
Transformers
Safetensors
English
lfm2
liquid
edge
extraction
fact-checking
spelling-creator
trl
sft
conversational
Instructions to use playforgecoding/LFM2-350M-Extract-facts with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use playforgecoding/LFM2-350M-Extract-facts with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="playforgecoding/LFM2-350M-Extract-facts") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("playforgecoding/LFM2-350M-Extract-facts") model = AutoModelForCausalLM.from_pretrained("playforgecoding/LFM2-350M-Extract-facts", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use playforgecoding/LFM2-350M-Extract-facts with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "playforgecoding/LFM2-350M-Extract-facts" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "playforgecoding/LFM2-350M-Extract-facts", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/playforgecoding/LFM2-350M-Extract-facts
- SGLang
How to use playforgecoding/LFM2-350M-Extract-facts with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "playforgecoding/LFM2-350M-Extract-facts" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "playforgecoding/LFM2-350M-Extract-facts", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "playforgecoding/LFM2-350M-Extract-facts" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "playforgecoding/LFM2-350M-Extract-facts", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use playforgecoding/LFM2-350M-Extract-facts with Docker Model Runner:
docker model run hf.co/playforgecoding/LFM2-350M-Extract-facts
|
Download README.md from playforgecoding/LFM2-350M-Extract-facts: direct link, hf CLI and curl.
- Browser
- Download file 4.08 kB
-
https://huggingface.co/playforgecoding/LFM2-350M-Extract-facts/resolve/main/README.md
- Command line
-
hf download hf://playforgecoding/LFM2-350M-Extract-facts/README.md
-
curl -L -o README.md https://huggingface.co/playforgecoding/LFM2-350M-Extract-facts/resolve/main/README.md
4.08 kB
| license: other | |
| license_name: lfm1.0 | |
| license_link: LICENSE | |
| language: | |
| - en | |
| pipeline_tag: text-generation | |
| library_name: transformers | |
| base_model: LiquidAI/LFM2-350M-Extract | |
| datasets: | |
| - playforgecoding/spelling-creator-fact-claims | |
| tags: | |
| - liquid | |
| - lfm2 | |
| - edge | |
| - extraction | |
| - fact-checking | |
| - spelling-creator | |
| - trl | |
| - sft | |
| # LFM2-350M-Extract, fine-tuned to list checkable facts in lesson passages | |
| The merged weights (bf16, safetensors). For the browser or Node, use the ONNX | |
| export at | |
| [playforgecoding/LFM2-350M-Extract-facts-ONNX](https://huggingface.co/playforgecoding/LFM2-350M-Extract-facts-ONNX). | |
| **Experimental.** It is not used by Spelling Creator: on held-out lessons it | |
| still names the subject of a fact wrong half the time, which turns into false | |
| alarms in a fact check (see Results). | |
| ## What it does | |
| Reads one passage of a lesson and lists the facts in it that can be checked | |
| against Wikidata: a number, a date or a named thing stated about one specific, | |
| named, real thing ("Mount Everest rises 8,849 METRES", "CANBERRA is the | |
| capital"). Each claim has the exact words it rests on (`quote`), what it is | |
| about (`subject`, `kind`), which `property` it states, and the `value` and | |
| `unit` or the `stated` name. It never says whether a fact is right; that is | |
| done in code against Wikidata. | |
| It is a fine-tune of | |
| [LiquidAI/LFM2-350M-Extract](https://huggingface.co/LiquidAI/LFM2-350M-Extract) | |
| for [Spelling Creator](https://github.com/Spelling-Creator/spelling-creator), a | |
| lesson builder for Spelling to Communicate (S2C), where lessons are read aloud | |
| to nonspeaking spellers. Spelling Creator's fact check asks a hosted model for | |
| the claims today; a model like this one would let the whole check run on the | |
| device. | |
| ## Training | |
| LoRA (rank 16, learning rate 2e-4, 5 epochs, 3072-token context) on the | |
| [spelling-creator-fact-claims](https://huggingface.co/datasets/playforgecoding/spelling-creator-fact-claims) | |
| dataset: 347 passages and 750 claims, from 10 hub lessons and 116 sections | |
| written for coverage, 96 of the passages with nothing to list. The labels are | |
| Claude Opus's, made with the same prompt Spelling Creator's server sends its | |
| own provider. Only the reply carries loss. Two hub lessons (24 passages, 20 | |
| claims) are held out. The scripts are in the Spelling Creator repo under | |
| `packages/core/scripts/fact-eval/`. | |
| ## Results | |
| The int8 ONNX export on the 24 held-out passages: | |
| | metric | stock 350M | this model | | |
| | --------------------------------------------- | ---------: | ---------: | | |
| | replies in the schema | 16/24 | 24/24 | | |
| | labelled claims found | 0% | 50% | | |
| | listed claims that match a label | n/a | 42% | | |
| | quotes not in the passage | 243 | 2 | | |
| | empty list for a passage with nothing to list | 0/13 | 8/13 | | |
| | subject named right, of the claims found | n/a | 50% | | |
| Run through the real checker against Wikidata, its claims give 2 false alarms | |
| (a right fact reported as contradicted by Wikidata) in those 24 passages, | |
| both from a wrong subject or a date the rules say to leave out, and miss 9 of | |
| the 14 findings the labels give. The value, unit and qualifier of the claims | |
| it does find are almost always right; naming the subject is what it cannot do | |
| at this size. The write-up is at | |
| [spellingcreator.org/docs/monorepo/fact-claim-model](https://spellingcreator.org/docs/monorepo/fact-claim-model). | |
| ## Prompt | |
| The system prompt is the rules (which facts count, the properties with a short | |
| description each, how to choose between near ones, what each field means) and | |
| the JSON Schema of the reply; the user turn is `Lesson: <title>`, a blank line | |
| and the passage. Greedy decoding. The exact text is `passageClaimsSystemPrompt` | |
| in `packages/core/src/factClaims.js`, and every training example carries it. | |
| ## Licence | |
| Derived from LFM2-350M-Extract and released under the same LFM Open License | |
| v1.0 (see LICENSE). | |