Instructions to use sabankara/einstein with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sabankara/einstein with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sabankara/einstein")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("sabankara/einstein") model = AutoModelForSeq2SeqLM.from_pretrained("sabankara/einstein", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sabankara/einstein with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sabankara/einstein" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sabankara/einstein", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/sabankara/einstein
- SGLang
How to use sabankara/einstein 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 "sabankara/einstein" \ --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": "sabankara/einstein", "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 "sabankara/einstein" \ --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": "sabankara/einstein", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use sabankara/einstein with Docker Model Runner:
docker model run hf.co/sabankara/einstein
|
Download README.md from sabankara/einstein: direct link, hf CLI and curl.
- Browser
- Download file 2.42 kB
-
https://huggingface.co/sabankara/einstein/resolve/refs%2Fpr%2F13/README.md
- Command line
-
hf download hf://sabankara/einstein@refs/pr/13/README.md
-
curl -L -H "Authorization: Bearer $HF_TOKEN" -o README.md https://huggingface.co/sabankara/einstein/resolve/refs%2Fpr%2F13/README.md
2.42 kB
| license: apache-2.0 | |
| metrics: | |
| - accuracy | |
| pipeline_tag: text2text-generation | |
| tags: | |
| - legal | |
| - text-generation-inference | |
| datasets: | |
| - lgaalves/camel-ai-physics | |
| ### Model Description | |
| This model is trained on a large physics dataset, specifically “Special Relativity,” “Dark Matter,” “Black Holes,” “Quantum Mechanics,” “Plasma Physics,” “Particle Physics,” “Specific Theory,” “Nuclear Physics.” Provides expertise in "Atomic Physics," "Quantum Field Theory," "Gravitational Waves," "Electromagnetism," and "Chaotic Theory." It has the ability to provide information on a wide range of subjects, with the ability to answer physics questions under these headings. | |
| ``` python | |
| from transformers import AutoTokenizer, GenerationConfig, T5ForConditionalGeneration | |
| import torch | |
| from peft import PeftModel | |
| import time | |
| import sys | |
| repo_id = "sabankara/einstein" | |
| model_name = 'google/flan-t5-small' | |
| tokenizer = AutoTokenizer.from_pretrained(repo_id,device=0) | |
| peft_model_base = T5ForConditionalGeneration.from_pretrained(model_name, torch_dtype=torch.bfloat16, local_files_only=True, device_map= {"":0}) | |
| peft_model = PeftModel.from_pretrained(peft_model_base, | |
| repo_id, | |
| torch_dtype=torch.bfloat16, | |
| is_trainable=False) | |
| def print_character_by_character(text, delay=0.005, color_code="\033[36m"): | |
| for char in text: | |
| sys.stdout.write(f"{color_code}{char}\033[0m") | |
| sys.stdout.flush() | |
| time.sleep(delay) | |
| def add_newline_after_punctuation(text): | |
| n=17 | |
| words = text.split() | |
| updated_text = "" | |
| for i, word in enumerate(words): | |
| updated_text += word + " " | |
| if (i + 1) % n == 0: | |
| updated_text += "\n" | |
| return updated_text.strip() | |
| #example | |
| prompt ="what is the black hole?" | |
| input_ids = tokenizer(prompt, return_tensors="pt").input_ids.cuda(0) | |
| model_outputs = peft_model.generate(input_ids=input_ids, generation_config=GenerationConfig(min_new_tokens= 100, max_new_tokens=512, num_beams=1, do_sample=True, top_p=0.6, top_k=0, temperature=0.4,repetition_penalty=2.5)) | |
| model_text_output = tokenizer.decode(model_outputs[0], skip_special_tokens=True) | |
| albert_response = add_newline_after_punctuation(model_text_output) | |
| print("\033[32mEintein:\033[0m") | |
| print_character_by_character(albert_response) | |
| sys.stdout.write("\n") | |
| ``` |