MalayaLLM[മലയാളം/Malayalam]: Gemma-7B
Collection
Gemma based Malayalam pretrained , finetuned models • 3 items • Updated • 2
How to use VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1")
model = AutoModelForCausalLM.from_pretrained("VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1")How to use VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1
How to use VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1" \
--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": "VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1" \
--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": "VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1 with Docker Model Runner:
docker model run hf.co/VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1
Discover the mind behind this model and stay updated on their contributions to the field https://www.linkedin.com/in/vishnu-prasad-j/
The MalayaLLM models have been improved and customized expanding upon the groundwork laid by the original Gemma model.
float16Latest Gemma2-9B trained model is here :MalayaLLM:Gemma-2-9B
# Installs Unsloth, Xformers (Flash Attention) and all other packages!
#!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
#!pip install --no-deps xformers "trl<0.9.0" peft accelerate bitsandbytes
import sentencepiece as spm
from unsloth import FastLanguageModel
import torch
max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="VishnuPJ/MalayaLLM_Gemma_7B_Instruct_V1",
max_seq_length=max_seq_length,
dtype=dtype,
load_in_4bit=load_in_4bit,
)
EOS_TOKEN = tokenizer.eos_token # Must add EOS_TOKEN
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
#### Giving Instruction with Input
'''
alpaca_prompt_1 = """ഒരു ചുമതല വിവരിക്കുന്ന ഒരു നിർദ്ദേശം ചുവടെയുണ്ട്.
അഭ്യർത്ഥന ശരിയായി പൂർത്തിയാക്കുന്ന ഒരു പ്രതികരണം എഴുതുക.".
### നിർദ്ദേശം:
{}
### ഇൻപുട്ട്:
{}
### പ്രതികരണം:
{}"""
inputs = tokenizer([
alpaca_prompt_1.format(
# "Continue the fibonnaci sequence.", # instruction
"""താഴെ ഉള്ള വാക്യത്തിൽ "അത്" എന്ന് പറയുന്നത് എന്തിനെ ആണ് ?""", # instruction
""" ഒരു വാഹനം കയറ്റം കയറുക ആയിരുന്നു .അതിൽ 4 ആൾക്കാർ ഉണ്ടായിരുന്നു. """, # input
"", # output - leave this blank for generation!
)
], return_tensors = "pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=128, use_cache=True)
# Printing the result
print(tokenizer.batch_decode(outputs)[0].split("പ്രതികരണം:\n")[-1])
'''
## Giving Instruction only.
alpaca_prompt_2 = """ഒരു ചുമതല വിവരിക്കുന്ന ഒരു നിർദ്ദേശം ചുവടെയുണ്ട്.
അഭ്യർത്ഥന ശരിയായി പൂർത്തിയാക്കുന്ന ഒരു പ്രതികരണം എഴുതുക.".
### നിർദ്ദേശം:
{}
### പ്രതികരണം:
{}"""
while True:
# Taking user input for the instruction
instruction = input("Enter the instruction (or type 'exit' to quit): ")
if instruction.lower() == 'exit':
break
# Preparing the input for the model
inputs = tokenizer([
alpaca_prompt_2.format(
instruction,
"", # output - leave this blank for generation!
)
], return_tensors="pt").to("cuda")
# Generating the output
outputs = model.generate(**inputs, max_new_tokens=128, use_cache=True)
# Printing the result
print(tokenizer.batch_decode(outputs)[0].split("പ്രതികരണം:\n")[-1])
print("Program terminated.")
''''
Enter instruction (or 'exit' to end): ഒരു സമചതുരത്തിന്റെ ഒരു വശം 4 cm ആണെങ്കിൽ , അതിന്റെ area കണ്ടുപിടിക്കുക..
സമചതുരത്തിന്റെ area 16 cm2 ആണ്.<eos>.
Enter instruction (or 'exit' to end): ഇന്ത്യയുടെ അടുത്ത് സ്ഥിതി ചെയുന്ന നാല് രാജ്യങ്ങളുടെ പേര് പറയുക.
"ഇന്ത്യയ്ക്ക് സമീപമുള്ള നാല് രാജ്യങ്ങൾ ഇവയാണ്:
- നേപ്പാൾ
- ഭൂട്ടാൻ
- ടിബറ്റ് (ചൈന)
- പാകിസ്ഥാൻ"<eos>
Enter instruction (or 'exit' to end):exit
Thanks to Unsloth, the process of fine-tuning large language models (LLMs) has become much easier and more efficient.
