Helsinki-NLP/opus-100
Viewer • Updated • 55.1M • 28.6k • 235
How to use sign/WeLT-string-repetition with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="sign/WeLT-string-repetition") # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("sign/WeLT-string-repetition", dtype="auto")How to use sign/WeLT-string-repetition with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "sign/WeLT-string-repetition"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "sign/WeLT-string-repetition",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/sign/WeLT-string-repetition
How to use sign/WeLT-string-repetition with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "sign/WeLT-string-repetition" \
--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": "sign/WeLT-string-repetition",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "sign/WeLT-string-repetition" \
--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": "sign/WeLT-string-repetition",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use sign/WeLT-string-repetition with Docker Model Runner:
docker model run hf.co/sign/WeLT-string-repetition
This model is traained using this config. It is designed to take in English strings, and repeat them.
It is published here, so that it can be used in tests.
from pathlib import Path
import torch
from transformers import GenerationConfig
from transformers.trainer_utils import get_last_checkpoint
from welt.model import WordLatentTransformerForCausalLM
from welt.processor import TextImageProcessor
with torch.no_grad():
model = WordLatentTransformerForCausalLM.from_pretrained("sign/WeLT-string-repetition")
processor = TextImageProcessor.from_pretrained(model_path)
model.eval()
texts = [
# Texts from validation set
"<text>\x0EWouldn't it be more cruel for society to let people die... - ... when with some effort it could save them?\x0F<repeat> ",
"<text>\x0ESuperman's exact opposite who lives in the backwards Bizarro World.\x0F<repeat> ",
"<text>\x0EYOu dOn't know the half Of it.\x0F<repeat> ",
]
inputs = processor(texts, collated=True, packed=False)
outputs = model.generate(
**inputs,
processor=processor,
max_generated_words=32,
)
for text, output in zip(texts, outputs, strict=False):
print(f"Generated for '{text}': {output}")