Instructions to use fraunhofer-iis/elmod-2.7b-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fraunhofer-iis/elmod-2.7b-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fraunhofer-iis/elmod-2.7b-it") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("fraunhofer-iis/elmod-2.7b-it") model = AutoModelForCausalLM.from_pretrained("fraunhofer-iis/elmod-2.7b-it", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use fraunhofer-iis/elmod-2.7b-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fraunhofer-iis/elmod-2.7b-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fraunhofer-iis/elmod-2.7b-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/fraunhofer-iis/elmod-2.7b-it
- SGLang
How to use fraunhofer-iis/elmod-2.7b-it 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 "fraunhofer-iis/elmod-2.7b-it" \ --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": "fraunhofer-iis/elmod-2.7b-it", "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 "fraunhofer-iis/elmod-2.7b-it" \ --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": "fraunhofer-iis/elmod-2.7b-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use fraunhofer-iis/elmod-2.7b-it with Docker Model Runner:
docker model run hf.co/fraunhofer-iis/elmod-2.7b-it
A problem with pre-tokenizer regex
In tokenizer.json we have:
"pretokenizers": [
{
"type": "Split",
"pattern": {
"Regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}{1,3}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|s+(?!\\S)|\\s+"
},
"behavior": "Isolated",
"invert": false
},
Note the '|s' near the end, shouldn't it be '|\\s' like in the original llama pre-tokenizer regex below?
{
"type": "Split",
"pattern": {
"Regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}{1,3}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+"
},
"behavior": "Isolated",
"invert": false
},
Hey, thanks for noticing! I don't think the double escape will make any difference while for AutoTokenizer, but we can test it.
Alright I have been checking this out. The Tokenizer causes a different behavior for this scenario:
"Hello World" (so anything with more than one whitespace char between two words.
current version: ['Hello', ' ', 'World']
version with "\s"-fix: ['Hello', ' ', ' World']
I think ordinary, the model should benefit from the fix, since it learns to connect the convention space-prefixed version of other tokens to situations, where there are more spaces involved. Right now it learned, that multi-spaces are connected to tokens, which are ordinary used as first tokens in sentences.
However, I did some perplexity check with a longer text using multi spaces instead of white spaces and the model was far off, using the fix. I therefore suggest to stay with this "broken" version, since we'd need to perform a retraining to really make use of it.
(Maybe there are some other situations affected by this bug, but I did not find them so far.)
Edit: remark, the formatting broke in this comment. Imagine multiple spaces in the above mentioned example
I compared perplexity in llama.cpp on CPP code. Used ggml/src/ggml-opencl/ggml-opencl.cpp from llama.cpp since it's very long.
With the original "broken" regex I have: Final estimate: PPL = 3.7883 +/- 0.02268
With the "corrected" regex I have: Final estimate: PPL = 4.3889 +/- 0.02808
So I guess it's a good decision to keep the original form used for training the model.