Instructions to use suayptalha/minGRULM-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use suayptalha/minGRULM-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="suayptalha/minGRULM-base", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("suayptalha/minGRULM-base", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use suayptalha/minGRULM-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "suayptalha/minGRULM-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "suayptalha/minGRULM-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/suayptalha/minGRULM-base
- SGLang
How to use suayptalha/minGRULM-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 "suayptalha/minGRULM-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": "suayptalha/minGRULM-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 "suayptalha/minGRULM-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": "suayptalha/minGRULM-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use suayptalha/minGRULM-base with Docker Model Runner:
docker model run hf.co/suayptalha/minGRULM-base
MinGRU Sentiment Analysis
First Hugging Face integration of minGRU models from the paper "Were RNNs All We Needed?".
This model uses GPT-2 tokenizer and trained on roneneldan/TinyStories dataset.
Note: This is an experimental model. Don't forget to train model before usage!
Make sure you have installed "minGRU-pytorch" library by running "pip install minGRU-pytorch".
For modeling and configuration codes: minGRU-hf
Training:
Training code:
def train_model(model, tokenizer, train_data, output_dir, epochs=3, batch_size=16, learning_rate=5e-5, block_size=128):
train_dataset = TinyStoriesDataset(train_data, tokenizer, block_size)
train_loader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True)
optimizer = torch.optim.AdamW(model.parameters(), lr=learning_rate)
scheduler = get_scheduler("linear", optimizer=optimizer, num_warmup_steps=0, num_training_steps=len(train_loader) * epochs)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
model.train()
for epoch in range(epochs):
print(f"Epoch {epoch + 1}/{epochs}")
epoch_loss = 0
progress_bar = tqdm(train_loader, desc="Training")
for batch in progress_bar:
batch = batch.to(device)
outputs = model(batch, labels=batch)
loss = outputs.loss
optimizer.zero_grad()
loss.backward()
optimizer.step()
scheduler.step()
epoch_loss += loss.item()
progress_bar.set_postfix(loss=loss.item())
print(f"Epoch {epoch + 1} Loss: {epoch_loss / len(train_loader)}")
model.save_pretrained(output_dir, safe_serialization = False)
tokenizer.save_pretrained(output_dir)
You can use this code snippet for fine-tuning!
Credits:
https://arxiv.org/abs/2410.01201
I am thankful to Leo Feng, Frederick Tung, Mohamed Osama Ahmed, Yoshua Bengio and Hossein Hajimirsadeghi for their papers.
- Downloads last month
- 11

