Practical overview
When it fits
Use Xgen when you want to experiment with the released model weights and can run the documented Transformers and PyTorch loading and generation workflow.
Who it is for
- Researchers experimenting with language models and autoregressive text generation.
- Developers who want to load and run a 7B model in a self-hosted setup.
Documented uses
- Generate text from a prompt using a base model.
- Experiment with longer input sequences using the 8K base variant.
- Compare the 4K and 8K base models.
- Explore an instruction-finetuned model for research.
Requirements & limits
The repository is public and specifies an Apache-2.0 license. The models are published on the Hugging Face Hub; the repository example loads them by model identifier.
- The base variants differ in supported sequence length: 4K versus 8K.
- The instruction-finetuned variant is identified as for research purposes only.
- The documented workflow uses Transformers, PyTorch, and Tiktoken; the example also sets bfloat16 and enables remote tokenizer code.
- Salesforce describes the release as research support and recommends evaluating accuracy, safety, and fairness for downstream uses.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Generate text with an XGen base model
Load the 8K base model and tokenizer, generate text from a prompt, and decode the sample.
Before you start
- Python environment with PyTorch and Hugging Face Transformers
- OpenAI Tiktoken package, used for tokenization
- A setup able to load the model weights with bfloat16, as shown in the repository example
Steps
Install Tiktoken with the command below.
pip install tiktokenLoad the
Salesforce/xgen-7b-8k-basetokenizer using Transformers andtrust_remote_code=True.Load the model with
AutoModelForCausalLM.from_pretrainedusingtorch_dtype=torch.bfloat16.Tokenize a prompt, call
model.generatewith a maximum output length, and decode the generated sample.
Expected outcome
A decoded text sample generated from the prompt using the 8K base model.
Guide limitations
- The repository example uses the 8K base model; it does not establish hardware requirements or performance.
- The release is for research purposes, and Salesforce recommends evaluating accuracy, safety, and fairness before downstream deployment.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 7 November 2026
- Original website title
- salesforce/xgen · Official homepage title · retained in its source language

