Instructions to use mohommed/Testing with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use mohommed/Testing with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-neo-1.3B") model = PeftModel.from_pretrained(base_model, "mohommed/Testing") - Transformers
How to use mohommed/Testing with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mohommed/Testing")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mohommed/Testing", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mohommed/Testing with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mohommed/Testing" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mohommed/Testing", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mohommed/Testing
- SGLang
How to use mohommed/Testing 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 "mohommed/Testing" \ --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": "mohommed/Testing", "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 "mohommed/Testing" \ --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": "mohommed/Testing", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mohommed/Testing with Docker Model Runner:
docker model run hf.co/mohommed/Testing
Download Main.py from mohommed/Testing: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/mohommed/Testing/resolve/main/Main.py
- Command line
-
hf download hf://mohommed/Testing/Main.py
-
curl -L -o Main.py https://huggingface.co/mohommed/Testing/resolve/main/Main.py
1.31 kB
| # Install dependencies | |
| !pip install transformers accelerate peft | |
| # Import libraries | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| from peft import PeftModel, PeftConfig | |
| import torch | |
| # Load base model and PEFT adapter | |
| base_model_name = "EleutherAI/gpt-neo-1.3B" | |
| peft_model_name = "mohommed/Testing" | |
| # Load tokenizer and base model | |
| tokenizer = AutoTokenizer.from_pretrained(base_model_name) | |
| base_model = AutoModelForCausalLM.from_pretrained(base_model_name, device_map="auto", torch_dtype=torch.float16) | |
| # Apply the PEFT adapter | |
| model = PeftModel.from_pretrained(base_model, peft_model_name) | |
| model.eval() | |
| # Define generation function | |
| def generate_article(prompt, max_new_tokens=700): | |
| inputs = tokenizer(prompt, return_tensors="pt").to(model.device) | |
| with torch.no_grad(): | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=max_new_tokens, | |
| temperature=0.8, | |
| top_p=0.95, | |
| do_sample=True, | |
| eos_token_id=tokenizer.eos_token_id, | |
| ) | |
| return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| # Example prompt | |
| prompt = "Write a 600-word Medium article about how to stay motivated as a writer. Use a personal tone and clear structure." | |
| # Generate article | |
| output = generate_article(prompt) | |
| print(output) | |