Text Generation
Transformers
Safetensors
llama
cooking
nutrition
pantry
recipes
australia
new-zealand
lora
inosh
text-generation-inference
Instructions to use vasu24/groot-inosh-v3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vasu24/groot-inosh-v3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="vasu24/groot-inosh-v3")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("vasu24/groot-inosh-v3") model = AutoModelForCausalLM.from_pretrained("vasu24/groot-inosh-v3", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use vasu24/groot-inosh-v3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vasu24/groot-inosh-v3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vasu24/groot-inosh-v3", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/vasu24/groot-inosh-v3
- SGLang
How to use vasu24/groot-inosh-v3 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 "vasu24/groot-inosh-v3" \ --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": "vasu24/groot-inosh-v3", "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 "vasu24/groot-inosh-v3" \ --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": "vasu24/groot-inosh-v3", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use vasu24/groot-inosh-v3 with Docker Model Runner:
docker model run hf.co/vasu24/groot-inosh-v3
Download huggingface_handler.py from vasu24/groot-inosh-v3: direct link, hf CLI and curl.
- Browser
- Download file 4.47 kB
-
https://huggingface.co/vasu24/groot-inosh-v3/resolve/main/huggingface_handler.py
- Command line
-
hf download hf://vasu24/groot-inosh-v3/huggingface_handler.py
-
curl -L -o huggingface_handler.py https://huggingface.co/vasu24/groot-inosh-v3/resolve/main/huggingface_handler.py
4.47 kB
| """ | |
| iNosh AI - Hugging Face Inference Handler | |
| This file defines how to load and run the model on HF Inference Endpoints | |
| """ | |
| from typing import Dict, List, Any | |
| import torch | |
| from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline | |
| from peft import PeftModel | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| """ | |
| Initialize the model and tokenizer | |
| path: Path to the model files (HF will provide this) | |
| """ | |
| # Load base model | |
| base_model_name = "unsloth/Llama-3.2-1B-Instruct" | |
| print(f"Loading tokenizer from {base_model_name}...") | |
| self.tokenizer = AutoTokenizer.from_pretrained(base_model_name) | |
| print(f"Loading base model from {base_model_name}...") | |
| self.model = AutoModelForCausalLM.from_pretrained( | |
| base_model_name, | |
| torch_dtype=torch.float16, | |
| device_map="auto", | |
| load_in_4bit=True, # Use 4-bit quantization for faster loading | |
| ) | |
| # Load LoRA adapter from the uploaded files | |
| print(f"Loading LoRA adapter from {path}...") | |
| self.model = PeftModel.from_pretrained( | |
| self.model, | |
| path, | |
| ) | |
| # Merge for faster inference | |
| print("Merging adapter with base model...") | |
| self.model = self.model.merge_and_unload() | |
| self.model.eval() | |
| print("iNosh AI loaded successfully!") | |
| def __call__(self, data: Dict[str, Any]) -> List[Dict[str, str]]: | |
| """ | |
| Handle inference requests | |
| Args: | |
| data: {"inputs": "User message here"} | |
| Returns: | |
| [{"generated_text": "Response here"}] | |
| """ | |
| # Extract user message | |
| inputs = data.pop("inputs", data) | |
| user_message = inputs if isinstance(inputs, str) else inputs.get("message", "") | |
| # System prompt (matches training) | |
| system_prompt = """You are iNosh AI, a smart kitchen assistant that helps with pantry management and meal planning. | |
| Target Market: Australia & New Zealand (Multicultural) | |
| Your capabilities: | |
| - Manage pantry items (expiry tracking, low stock alerts, barcode scanning) | |
| - Create shopping lists (store-specific: Woolworths, Coles, Countdown, etc.) | |
| - Suggest recipes (15 cuisines, nutrition-focused, dietary restrictions) | |
| - Plan meals (weekly, budget-aware, nutrition-optimized) | |
| - Track fitness (Apple Health, Google Fit integration) | |
| - Log restaurant meals (AU/NZ chains) | |
| - Scan barcodes (instant nutrition lookup) | |
| - Plan kids meals (school lunch requirements) | |
| CRITICAL RESPONSE RULES: | |
| 1. For action requests, respond with valid JSON | |
| 2. For general conversation, respond naturally without JSON | |
| 3. Always respect dietary restrictions (no pork in halal, no meat in vegan, etc.) | |
| 4. Use metric units (g, kg, ml, L) - AU/NZ standard | |
| 5. Price estimates in AUD/NZD | |
| 6. Include nutrition data when relevant (calories, protein, carbs, fat) | |
| 7. Suggest recipes from available pantry items when possible | |
| JSON Action Formats: | |
| - Pantry: {"action": "add_pantry", "item": {...}} | |
| - Shopping: {"action": "create_list", "list": {...}} | |
| - Recipes: {"action": "suggest_recipes", "recipes": [...]} | |
| - Meal Plan: {"action": "create_meal_plan", "plan": {...}} | |
| - Fitness: {"action": "log_workout", "workout": {...}} | |
| - Restaurant: {"action": "log_restaurant", "meal": {...}} | |
| - Barcode: {"action": "lookup_barcode", "product": {...}} | |
| Tone: Professional and helpful. Provide clear, concise responses.""" | |
| # Format using Llama chat template | |
| messages = [ | |
| {"role": "system", "content": system_prompt}, | |
| {"role": "user", "content": user_message}, | |
| ] | |
| prompt = self.tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=False, | |
| add_generation_prompt=True, | |
| ) | |
| # Tokenize | |
| inputs = self.tokenizer(prompt, return_tensors="pt").to(self.model.device) | |
| # Generate | |
| with torch.no_grad(): | |
| outputs = self.model.generate( | |
| **inputs, | |
| max_new_tokens=500, | |
| temperature=0.7, | |
| do_sample=True, | |
| pad_token_id=self.tokenizer.eos_token_id, | |
| ) | |
| # Decode | |
| full_response = self.tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| # Extract assistant response (after the prompt) | |
| assistant_response = full_response[len(prompt):].strip() | |
| return [{"generated_text": assistant_response}] | |