Instructions to use openGPT-X/Teuken-7B-instruct-research-v0.4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openGPT-X/Teuken-7B-instruct-research-v0.4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openGPT-X/Teuken-7B-instruct-research-v0.4")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openGPT-X/Teuken-7B-instruct-research-v0.4") model = AutoModelForCausalLM.from_pretrained("openGPT-X/Teuken-7B-instruct-research-v0.4", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openGPT-X/Teuken-7B-instruct-research-v0.4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openGPT-X/Teuken-7B-instruct-research-v0.4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openGPT-X/Teuken-7B-instruct-research-v0.4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/openGPT-X/Teuken-7B-instruct-research-v0.4
- SGLang
How to use openGPT-X/Teuken-7B-instruct-research-v0.4 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 "openGPT-X/Teuken-7B-instruct-research-v0.4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openGPT-X/Teuken-7B-instruct-research-v0.4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "openGPT-X/Teuken-7B-instruct-research-v0.4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openGPT-X/Teuken-7B-instruct-research-v0.4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use openGPT-X/Teuken-7B-instruct-research-v0.4 with Docker Model Runner:
docker model run hf.co/openGPT-X/Teuken-7B-instruct-research-v0.4
Problems with the OpenGPT-X tokenizer
Hello, and congratulations on the release! 🤗
I have tried to run some evaluations on the Teuken-7B-instruct-research-v0.4 but I keep encountering errors, which I believe come from the tokenizer.
Code to replicate (Transformers version: 4.42.3):
from transformers import GenerationConfig, TextGenerationPipeline, AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("openGPT-X/Teuken-7B-instruct-research-v0.4", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("openGPT-X/Teuken-7B-instruct-research-v0.4", trust_remote_code=True)
generation_config = GenerationConfig(max_new_tokens=100, do_sample=False)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
generator = TextGenerationPipeline(model=model, task="text-generation",
tokenizer=tokenizer, device=device)
completion = generator("My name is", generation_config=generation_config)
Trying to use the model via the TextGenerationPipeline has given me (weirdly...) two distinct errors:
RuntimeError: Boolean value of Tensor with more than one value is ambiguous
Which is an error coming from Sentencepiece (Sentencepiece version: 0.2.0). And:
TypeError: HFGPTXTokenizer.decode() got an unexpected keyword argument 'skip_special_tokens'
This error comes from the custom tokenizer. Could you please provide workarounds or push some patches? The skip_special_tokens error occurs when I try running this model on the Language Model Evaluation Harness, which works for most of the main models found in the Hub.
PS: Are there prospects for releasing a fast tokenizer?
Cheers!
forgot the code block specifier for Python ._.
Hi @nicholasKluge , thanks for pointing this out. It should be fixed now.
We will also look into fast tokenizers soon.