Text Generation
Transformers
Safetensors
English
lfm2
liquid
edge
extraction
spelling-creator
trl
sft
conversational
Instructions to use playforgecoding/LFM2-1.2B-Extract-lesson with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use playforgecoding/LFM2-1.2B-Extract-lesson with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="playforgecoding/LFM2-1.2B-Extract-lesson") 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-1.2B-Extract-lesson") model = AutoModelForCausalLM.from_pretrained("playforgecoding/LFM2-1.2B-Extract-lesson", 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-1.2B-Extract-lesson with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "playforgecoding/LFM2-1.2B-Extract-lesson" # 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-1.2B-Extract-lesson", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/playforgecoding/LFM2-1.2B-Extract-lesson
- SGLang
How to use playforgecoding/LFM2-1.2B-Extract-lesson 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-1.2B-Extract-lesson" \ --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-1.2B-Extract-lesson", "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-1.2B-Extract-lesson" \ --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-1.2B-Extract-lesson", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use playforgecoding/LFM2-1.2B-Extract-lesson with Docker Model Runner:
docker model run hf.co/playforgecoding/LFM2-1.2B-Extract-lesson
Card for the second fine-tune
Browse files
README.md
CHANGED
|
@@ -3,18 +3,20 @@ license: other
|
|
| 3 |
license_name: lfm1.0
|
| 4 |
license_link: LICENSE
|
| 5 |
language:
|
| 6 |
-
- en
|
| 7 |
pipeline_tag: text-generation
|
| 8 |
library_name: transformers
|
| 9 |
base_model: LiquidAI/LFM2-1.2B-Extract
|
|
|
|
|
|
|
| 10 |
tags:
|
| 11 |
-
- liquid
|
| 12 |
-
- lfm2
|
| 13 |
-
- edge
|
| 14 |
-
- extraction
|
| 15 |
-
- spelling-creator
|
| 16 |
-
- trl
|
| 17 |
-
- sft
|
| 18 |
---
|
| 19 |
|
| 20 |
# LFM2-1.2B-Extract, fine-tuned for Spelling Creator lesson documents
|
|
@@ -28,46 +30,59 @@ export at
|
|
| 28 |
Turns one section of a spelling lesson document, as a person might type it up
|
| 29 |
or as the app's own Word export reads back as plain text, into the lesson's
|
| 30 |
JSON: the passage paragraphs copied word for word, the spelling words, and
|
| 31 |
-
every question with its printed answers and working-out. It is a
|
|
|
|
| 32 |
[LiquidAI/LFM2-1.2B-Extract](https://huggingface.co/LiquidAI/LFM2-1.2B-Extract)
|
| 33 |
for [Spelling Creator](https://github.com/Spelling-Creator/spelling-creator), a
|
| 34 |
lesson builder for Spelling to Communicate (S2C), where lessons are read aloud
|
| 35 |
to nonspeaking spellers.
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
The stock Extract model handled this badly: it split paragraphs into
|
| 38 |
sentences, invented answers for open questions, and often abandoned the
|
| 39 |
schema. This fine-tune copies rather than invents.
|
| 40 |
|
| 41 |
## Training
|
| 42 |
|
| 43 |
-
LoRA (rank 16, learning rate 2e-4, 3 epochs, 4096-token context) on
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
`packages/core/scripts/extract-eval/`.
|
| 50 |
|
| 51 |
## Results
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
| 57 |
-
| ----------------------------------- | ----: |
|
| 58 |
-
|
|
| 59 |
-
|
|
| 60 |
-
|
|
| 61 |
-
|
|
| 62 |
-
|
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
[spellingcreator.org/docs/monorepo/document-import-experiment](https://spellingcreator.org/docs/monorepo/document-import-experiment).
|
| 72 |
|
| 73 |
## Prompt
|
|
@@ -75,7 +90,8 @@ documents the parser cannot read. The full write-up is at
|
|
| 75 |
The system prompt is `Return data as a JSON object with the following schema:`
|
| 76 |
followed by the JSON Schema of a section (`name`, `paragraphs`,
|
| 77 |
`spellingWords`, and `questions`, each with `prompt`, `type`, `answers` and
|
| 78 |
-
`steps`)
|
|
|
|
| 79 |
|
| 80 |
## Use
|
| 81 |
|
|
|
|
| 3 |
license_name: lfm1.0
|
| 4 |
license_link: LICENSE
|
| 5 |
language:
|
| 6 |
+
- en
|
| 7 |
pipeline_tag: text-generation
|
| 8 |
library_name: transformers
|
| 9 |
base_model: LiquidAI/LFM2-1.2B-Extract
|
| 10 |
+
datasets:
|
| 11 |
+
- playforgecoding/spelling-creator-document-import
|
| 12 |
tags:
|
| 13 |
+
- liquid
|
| 14 |
+
- lfm2
|
| 15 |
+
- edge
|
| 16 |
+
- extraction
|
| 17 |
+
- spelling-creator
|
| 18 |
+
- trl
|
| 19 |
+
- sft
|
| 20 |
---
|
| 21 |
|
| 22 |
# LFM2-1.2B-Extract, fine-tuned for Spelling Creator lesson documents
|
|
|
|
| 30 |
Turns one section of a spelling lesson document, as a person might type it up
|
| 31 |
or as the app's own Word export reads back as plain text, into the lesson's
|
| 32 |
JSON: the passage paragraphs copied word for word, the spelling words, and
|
| 33 |
+
every question with its printed answers, type and working-out. It is a
|
| 34 |
+
fine-tune of
|
| 35 |
[LiquidAI/LFM2-1.2B-Extract](https://huggingface.co/LiquidAI/LFM2-1.2B-Extract)
|
| 36 |
for [Spelling Creator](https://github.com/Spelling-Creator/spelling-creator), a
|
| 37 |
lesson builder for Spelling to Communicate (S2C), where lessons are read aloud
|
| 38 |
to nonspeaking spellers.
|
| 39 |
|
| 40 |
+
Spelling Creator reads typed lessons with rules first, and only hands this
|
| 41 |
+
model the sections the rules cannot read: questions typed with no question
|
| 42 |
+
marks or numbers, an answer left glued to its question, a numbered list that
|
| 43 |
+
lost its line breaks. This is the second fine-tune, trained on exactly those.
|
| 44 |
+
|
| 45 |
The stock Extract model handled this badly: it split paragraphs into
|
| 46 |
sentences, invented answers for open questions, and often abandoned the
|
| 47 |
schema. This fine-tune copies rather than invents.
|
| 48 |
|
| 49 |
## Training
|
| 50 |
|
| 51 |
+
LoRA (rank 16, learning rate 2e-4, 3 epochs, 4096-token context) on the
|
| 52 |
+
[spelling-creator-document-import](https://huggingface.co/datasets/playforgecoding/spelling-creator-document-import)
|
| 53 |
+
dataset: 521 sections from 10 lessons published on the Spelling Creator hub,
|
| 54 |
+
each rendered in 9 layouts and paired with the section's lesson JSON. Seven
|
| 55 |
+
layouts the app's rules read (its Word export as raw text, and six typed-up
|
| 56 |
+
styles), and two they cannot, from which only the sections the app would
|
| 57 |
+
really send to the model are kept, laid out exactly as it sends them. The two
|
| 58 |
+
newest lessons (108 sections) are held out. The data generator and the
|
| 59 |
+
training notebook are in the Spelling Creator repo under
|
| 60 |
`packages/core/scripts/extract-eval/`.
|
| 61 |
|
| 62 |
## Results
|
| 63 |
|
| 64 |
+
The int8 ONNX export, on every section of both held-out lessons (12 per
|
| 65 |
+
layout):
|
| 66 |
+
|
| 67 |
+
| layout | parsed | answers | composite |
|
| 68 |
+
| ---------------------------- | -----: | ------: | --------: |
|
| 69 |
+
| no question marks or numbers | 100% | 97% | 96% |
|
| 70 |
+
| numbered list on one line | 92% | 91% | 89% |
|
| 71 |
+
| Word export as raw text | 100% | 99% | 96% |
|
| 72 |
+
| numbered, bracketed answers | 100% | 100% | 97% |
|
| 73 |
+
| Q and A lines | 100% | 100% | 94% |
|
| 74 |
+
| bare capitals, no headings | 100% | 99% | 96% |
|
| 75 |
+
| bullets, square brackets | 92% | 92% | 89% |
|
| 76 |
+
| numbered, colon | 100% | 96% | 96% |
|
| 77 |
+
| working-out on its own line | 92% | 92% | 88% |
|
| 78 |
+
|
| 79 |
+
On the first two, the layouts the app actually sends it, Spelling Creator's
|
| 80 |
+
rules score 66 and 40 percent. Every row under 94 percent is one section in
|
| 81 |
+
twelve whose reply is not valid JSON (a key in the wrong place, a bare string
|
| 82 |
+
where a question belonged, a reply that repeated itself), which the app shows
|
| 83 |
+
as unread. On the sections that parse, every layout is 96 to 100 percent. The
|
| 84 |
+
model's own question types are right 87 to 97 percent of the time, above the
|
| 85 |
+
app's rule for deriving them, so the app keeps them. The full write-up is at
|
| 86 |
[spellingcreator.org/docs/monorepo/document-import-experiment](https://spellingcreator.org/docs/monorepo/document-import-experiment).
|
| 87 |
|
| 88 |
## Prompt
|
|
|
|
| 90 |
The system prompt is `Return data as a JSON object with the following schema:`
|
| 91 |
followed by the JSON Schema of a section (`name`, `paragraphs`,
|
| 92 |
`spellingWords`, and `questions`, each with `prompt`, `type`, `answers` and
|
| 93 |
+
`steps`) and a short guide to the question types; the user turn is the
|
| 94 |
+
section's text. Greedy decoding.
|
| 95 |
|
| 96 |
## Use
|
| 97 |
|