Instructions to use google/reformer-crime-and-punishment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/reformer-crime-and-punishment with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="google/reformer-crime-and-punishment")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("google/reformer-crime-and-punishment") model = AutoModelForCausalLM.from_pretrained("google/reformer-crime-and-punishment") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use google/reformer-crime-and-punishment with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/reformer-crime-and-punishment" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/reformer-crime-and-punishment", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/google/reformer-crime-and-punishment
- SGLang
How to use google/reformer-crime-and-punishment 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 "google/reformer-crime-and-punishment" \ --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": "google/reformer-crime-and-punishment", "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 "google/reformer-crime-and-punishment" \ --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": "google/reformer-crime-and-punishment", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use google/reformer-crime-and-punishment with Docker Model Runner:
docker model run hf.co/google/reformer-crime-and-punishment
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Reformer Model trained on "Crime and Punishment"
Crime and Punishment is a novel written by Fyodor Dostoevsky and was translated into English.
Crime and Punishment training data was taken from gs://trax-ml/reformer/crime-and-punishment-2554.txt and contains
roughly 0.5M tokens.
The ReformerLM model was trained in flax using colab notebook proposed by authors: https://colab.research.google.com/github/google/trax/blob/master/trax/models/reformer/text_generation.ipynb and the weights were converted to Hugging Face's PyTorch ReformerLM model ReformerModelWithLMHead.
The model is a language model that operates on small sub-word units. Text can be generated as follows:
model = ReformerModelWithLMHead.from_pretrained("google/reformer-crime-and-punishment")
tok = ReformerTokenizer.from_pretrained("google/reformer-crime-and-punishment")
tok.decode(model.generate(tok.encode("A few months later", return_tensors="pt"), do_sample=True,temperature=0.7, max_length=100)[0])
# gives:'A few months later on was more than anything in the flat.
# βI have already.β βThatβs not my notion that he had forgotten him.
# What does that matter? And why do you mean? Itβs only another fellow,β he said as he went out, as though he want'
- Downloads last month
- 130,695