Text Generation
Transformers
Safetensors
Chinese
English
lfm3
lfm3_v9
memory
custom_code
llama-factory
conversational
Instructions to use LTM-Lab/LFM3-1.7B-v9 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LTM-Lab/LFM3-1.7B-v9 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="LTM-Lab/LFM3-1.7B-v9", trust_remote_code=True) 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("LTM-Lab/LFM3-1.7B-v9", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("LTM-Lab/LFM3-1.7B-v9", trust_remote_code=True, 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 LTM-Lab/LFM3-1.7B-v9 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LTM-Lab/LFM3-1.7B-v9" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LTM-Lab/LFM3-1.7B-v9", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/LTM-Lab/LFM3-1.7B-v9
- SGLang
How to use LTM-Lab/LFM3-1.7B-v9 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 "LTM-Lab/LFM3-1.7B-v9" \ --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": "LTM-Lab/LFM3-1.7B-v9", "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 "LTM-Lab/LFM3-1.7B-v9" \ --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": "LTM-Lab/LFM3-1.7B-v9", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use LTM-Lab/LFM3-1.7B-v9 with Docker Model Runner:
docker model run hf.co/LTM-Lab/LFM3-1.7B-v9
Download config.json from LTM-Lab/LFM3-1.7B-v9: direct link, hf CLI and curl.
- Browser
- Download file 2.32 kB
-
https://huggingface.co/LTM-Lab/LFM3-1.7B-v9/resolve/main/config.json
- Command line
-
hf download hf://LTM-Lab/LFM3-1.7B-v9/config.json
-
curl -L -o config.json https://huggingface.co/LTM-Lab/LFM3-1.7B-v9/resolve/main/config.json
2.32 kB
| { | |
| "architectures": [ | |
| "Lfm3V9ForCausalLM" | |
| ], | |
| "auto_map": { | |
| "AutoConfig": "configuration_lfm3.Lfm3Config", | |
| "AutoModel": "modeling_lfm3_v9.Lfm3Model", | |
| "AutoModelForCausalLM": "modeling_lfm3_v9.Lfm3V9ForCausalLM" | |
| }, | |
| "bos_token_id": 124894, | |
| "conv_L_cache": 7, | |
| "conv_bias": false, | |
| "dtype": "bfloat16", | |
| "eos_token_id": 124900, | |
| "head_dim": 128, | |
| "hidden_size": 2048, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 7680, | |
| "layer_types": [ | |
| "conv", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "sliding_attention", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "sliding_attention", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "sliding_attention", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "sliding_attention", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "sliding_attention", | |
| "conv", | |
| "full_attention", | |
| "conv" | |
| ], | |
| "lfm3_v9_memory_config": { | |
| "context_window": 16, | |
| "copy_prior": 0.9, | |
| "copy_sharpness": 20.0, | |
| "copy_threshold": 0.9, | |
| "dilation": 3, | |
| "expert_prior": 0.5, | |
| "index": "exact", | |
| "index_bits": 16, | |
| "index_tables": 4, | |
| "kernel_size": 4, | |
| "key_dim": 64, | |
| "key_space_check": true, | |
| "layers": [ | |
| 1 | |
| ], | |
| "lifecycle": "auto", | |
| "namespace": "LFM3-1.7B@lfm3_v9@weights-0c801705bf03f5c9", | |
| "read_candidates": 32, | |
| "recency_half_life": null, | |
| "sharpness": 20.0, | |
| "smoothing": 0.1, | |
| "storage_limit_bytes": null, | |
| "storage_path": null, | |
| "suffix_gain": 4.0, | |
| "surprise_min_statistics": 16, | |
| "surprise_threshold": 1.0, | |
| "temporal_reads": 4, | |
| "time_frequencies": 8, | |
| "value_dim": 64, | |
| "write_policy": "all" | |
| }, | |
| "lfm3_v9_template_mask": true, | |
| "max_position_embeddings": 262144, | |
| "model_type": "lfm3", | |
| "norm_eps": 1e-05, | |
| "num_attention_heads": 16, | |
| "num_hidden_layers": 24, | |
| "num_key_value_heads": 4, | |
| "pad_token_id": 124893, | |
| "rope_parameters": { | |
| "full_attention": { | |
| "partial_rotary_factor": 0.5, | |
| "rope_theta": 1000000.0, | |
| "rope_type": "default" | |
| }, | |
| "sliding_attention": { | |
| "rope_theta": 10000, | |
| "rope_type": "default" | |
| } | |
| }, | |
| "sliding_window": 256, | |
| "tie_word_embeddings": true, | |
| "transformers_version": "5.19.0", | |
| "use_cache": true, | |
| "use_sandwich_norm": true, | |
| "vocab_size": 128000 | |
| } | |