初始化项目,由ModelHub XC社区提供模型
Model: Factor168/lfm2-hybridai-perls-sft-merged Source: Original Platform
This commit is contained in:
100
README.md
Normal file
100
README.md
Normal file
@@ -0,0 +1,100 @@
|
||||
---
|
||||
license: apache-2.0
|
||||
base_model: LiquidAI/LFM2-1.2B
|
||||
tags:
|
||||
- sft
|
||||
- gestalt
|
||||
library_name: transformers
|
||||
pipeline_tag: text-generation
|
||||
---
|
||||
|
||||
# Factor168/lfm2-hybridai-perls-sft-merged
|
||||
|
||||
Full merged checkpoint of `LiquidAI/LFM2-1.2B` fine-tuned (LoRA, merged) on Gestalt dialogue
|
||||
(Bry=user, Fritz=assistant) using 1–10 turn sliding windows from `perls/perls_sft.jsonl`
|
||||
(combined `perls.txt` + `perls_synth.txt`).
|
||||
|
||||
## Model Details
|
||||
- Base: `LiquidAI/LFM2-1.2B`
|
||||
- Method: LoRA SFT, merged into base (`merge_and_unload`)
|
||||
- Epochs: 2
|
||||
- Precision during training: bf16 if available, else fp16/float32
|
||||
- Repo type: full merged model (no external adapter needed)
|
||||
|
||||
## Data
|
||||
- Source: `perls/perls_sft.jsonl`
|
||||
- Format: chat `messages` with user/assistant roles
|
||||
- Preprocessing: 1–10 turn sliding windows over each conversation
|
||||
|
||||
## Training (script)
|
||||
- Script: `perls/train_perls_sft_lora.py`
|
||||
- LR: 2e-4 (default in script)
|
||||
- Batch: see script defaults (per_device_train_batch_size=4, grad_accum=2)
|
||||
- Warmup ratio: 0.03
|
||||
- Weight decay: 0.01
|
||||
|
||||
## Inference (Transformers)
|
||||
Recommended sampling (matches training demo):
|
||||
- temperature=0.3
|
||||
- min_p=0.15
|
||||
- repetition_penalty=1.05
|
||||
|
||||
Example outputs after fine-tuning (using the same sampling parameters):
|
||||
|
||||
- User: Ich bin gestresst.
|
||||
Assistant: Richtig! Was machen Sie mit dem Stress?
|
||||
- User: Ich kann mich nicht motivieren.
|
||||
Assistant: Das ist eine Stimmung, nicht ein Problem.
|
||||
- User: Ich habe Angst.
|
||||
Assistant: Natürlich! Angst ist eine gute Begleiterin. Was ist Ihre Hauptangst?
|
||||
- User: Wer sind Sie?
|
||||
Assistant: Sie sind alles, was ich bin.
|
||||
- User: Dr. Perls, was machen Sie?
|
||||
Assistant: Ich beobachte Sie!
|
||||
- User: Was ist Gestalttherapie?
|
||||
Assistant: Ich mag sie nicht!
|
||||
|
||||
## Tokenized prompts (input_ids)
|
||||
- `Ich bin gestresst.` → [1, 21221, 11572, 6658, 1276, 820, 523]
|
||||
- `Ich kann mich nicht motivieren.` → [1, 21221, 6417, 16169, 3355, 19044, 6110, 523]
|
||||
- `Ich habe Angst.` → [1, 21221, 12845, 63888, 523]
|
||||
- `Wer sind Sie?` → [1, 34633, 3987, 3612, 540]
|
||||
- `Dr. Perls, was machen Sie?` → [1, 9549, 523, 3563, 4442, 521, 953, 18532, 3612, 540]
|
||||
- `Was ist Gestalttherapie?` → [1, 28519, 2168, 22185, 2369, 1118, 39134, 540]
|
||||
|
||||
```python
|
||||
import torch
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
repo = "Factor168/lfm2-hybridai-perls-sft-merged"
|
||||
tok = AutoTokenizer.from_pretrained(repo)
|
||||
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype="auto").eval()
|
||||
|
||||
prompt = "Ich bin gestresst."
|
||||
text = tok.apply_chat_template(
|
||||
[{"role": "user", "content": prompt}],
|
||||
tokenize=False,
|
||||
add_generation_prompt=True,
|
||||
)
|
||||
inputs = tok(text, return_tensors="pt").to(model.device)
|
||||
out = model.generate(
|
||||
**inputs,
|
||||
max_new_tokens=256,
|
||||
do_sample=True,
|
||||
temperature=0.3,
|
||||
min_p=0.15,
|
||||
repetition_penalty=1.05,
|
||||
pad_token_id=tok.pad_token_id,
|
||||
)
|
||||
print(tok.decode(out[0, inputs['input_ids'].shape[1]:], skip_special_tokens=True))
|
||||
```
|
||||
|
||||
## Inference (vLLM)
|
||||
vLLM can load this merged checkpoint directly:
|
||||
```
|
||||
vllm serve Factor168/lfm2-hybridai-perls-sft-merged --tensor-parallel-size 1 --max-model-len 2048
|
||||
```
|
||||
|
||||
## Notes
|
||||
- This is a small, domain-specific SFT; outputs may be terse or stylistically like the source dialogues.
|
||||
- Safety/quality: no safety tuning; review outputs before production use.
|
||||
Reference in New Issue
Block a user