Run this model with HF Jobs
Run Salesforce/xgen-7b-8k-base on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/Salesforce/xgen-7b-8k-base. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Salesforce/xgen-7b-8k-base on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/Salesforce/xgen-7b-8k-base. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/Salesforce/xgen-7b-8k-base. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use Salesforce/xgen-7b-8k-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Salesforce/xgen-7b-8k-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Salesforce/xgen-7b-8k-base")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Salesforce/xgen-7b-8k-base") model = AutoModelForCausalLM.from_pretrained("Salesforce/xgen-7b-8k-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Salesforce/xgen-7b-8k-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Salesforce/xgen-7b-8k-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Salesforce/xgen-7b-8k-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Salesforce/xgen-7b-8k-base
- SGLang
How to use Salesforce/xgen-7b-8k-base 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 "Salesforce/xgen-7b-8k-base" \ --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": "Salesforce/xgen-7b-8k-base", "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 "Salesforce/xgen-7b-8k-base" \ --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": "Salesforce/xgen-7b-8k-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Salesforce/xgen-7b-8k-base with Docker Model Runner:
docker model run hf.co/Salesforce/xgen-7b-8k-base
tokenizer.get_vocab() method is not working
Hi team ,
There is an major issue with the tokenizer.get_vocab() method, as get_vocab() is a very important method that is used by a lot of codebases and libraries..for example ctranslate2
Having an issue over here renders the model useless for many usecases
Below are my logs and a possible fix
Thanks,
How to reproduce?
tokenizer = AutoTokenizer.from_pretrained("Salesforce/xgen-7b-8k-base",trust_remote_code=True)
tokenizer.get_vocab()
Possible Fix?
def _convert_id_to_token(self, index):
"""Converts an index (integer) in a token (str) using the vocab."""
return self.encoder.decode_single_token_bytes(index).decode("utf-8")
return self.encoder.decode_single_token_bytes(index).decode("latin1")
Use latin1 encoding over here instead of "utf-8"
Error thrown?
UnicodeDecodeError Traceback (most recent call last)
Cell In[39], line 1
----> 1 tokenizer.get_vocab()["<|tiktoken|>"]
File ~/.cache/huggingface/modules/transformers_modules/Salesforce/xgen-7b-8k-base/3987e094377fae577bba039af1b300ee8086f9e1/tokenization_xgen.py:142, in XgenTokenizer.get_vocab(self)
140 def get_vocab(self):
141 """Returns vocab as a dict"""
--> 142 vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
143 return vocab
File ~/.cache/huggingface/modules/transformers_modules/Salesforce/xgen-7b-8k-base/3987e094377fae577bba039af1b300ee8086f9e1/tokenization_xgen.py:142, in (.0)
140 def get_vocab(self):
141 """Returns vocab as a dict"""
--> 142 vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
143 return vocab
File ~/.cache/huggingface/modules/transformers_modules/Salesforce/xgen-7b-8k-base/3987e094377fae577bba039af1b300ee8086f9e1/tokenization_xgen.py:158, in XgenTokenizer._convert_id_to_token(self, index)
156 def _convert_id_to_token(self, index):
157 """Converts an index (integer) in a token (str) using the vocab."""
--> 158 return self.encoder.decode_single_token_bytes(index).decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 0: invalid start byte
Fixed, you can try again!
Thanks, the get vocab is working now
But still when trying to convert via ctranslate2 I'm getting the error that the model vocab size and the tokenizer vocab size does not match.
Can you check once