Instructions to use Hamses/EU_Regulation_261_2004 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Hamses/EU_Regulation_261_2004 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Hamses/EU_Regulation_261_2004")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Hamses/EU_Regulation_261_2004", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Hamses/EU_Regulation_261_2004 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Hamses/EU_Regulation_261_2004" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Hamses/EU_Regulation_261_2004", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Hamses/EU_Regulation_261_2004
- SGLang
How to use Hamses/EU_Regulation_261_2004 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 "Hamses/EU_Regulation_261_2004" \ --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": "Hamses/EU_Regulation_261_2004", "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 "Hamses/EU_Regulation_261_2004" \ --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": "Hamses/EU_Regulation_261_2004", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Hamses/EU_Regulation_261_2004 with Docker Model Runner:
docker model run hf.co/Hamses/EU_Regulation_261_2004
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Hamses/EU_Regulation_261_2004", dtype="auto")pip install transformers datasets torch
from datasets import load_dataset
Load your custom dataset (ensure it's in the proper format)
dataset = load_dataset('Hamses/EU_Regulation_261_2004', data_files={'train': 'train.txt', 'test': 'test.txt'})
Load the GPT-2 tokenizer
from transformers import GPT2Tokenizer
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
Preprocess the dataset
def preprocess_function(examples): return tokenizer(examples['text'], padding='max_length', truncation=True)
encoded_dataset = dataset.map(preprocess_function, batched=True)
from transformers import GPT2LMHeadModel, TrainingArguments, Trainer
Load the GPT-2 model
model = GPT2LMHeadModel.from_pretrained('gpt2')
Define training arguments
training_args = TrainingArguments(
output_dir='./results',
num_train_epochs=3,
per_device_train_batch_size=4,
per_device_eval_batch_size=4,
warmup_steps=500,
weight_decay=0.01,
logging_dir='./logs',
)
Initialize the Trainer
trainer = Trainer(
model=model,
args=training_args,
train_dataset=encoded_dataset['train'],
eval_dataset=encoded_dataset['test']
)
Train the model
trainer.train()
Evaluate the model
results = trainer.evaluate() print(results)
Save the model
model.save_pretrained('./gpt2-finetuned') tokenizer.save_pretrained('./gpt2-finetuned')
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Hamses/EU_Regulation_261_2004")