Spaces:
Sleeping
Sleeping
from huggingface_hub import hf_hub_download | |
from llama_cpp import Llama | |
import gradio as gr | |
import os | |
#from transformers import AutoModel, AutoTokenizer | |
os.makedirs("content", exist_ok=True) # Создание директории для сохранения модели | |
model_name = "aaditya/OpenBioLLM-Llama3-8B-GGUF" | |
model_file = "openbiollm-llama3-8b.Q5_K_M.gguf" | |
#tokenizer = AutoTokenizer.from_pretrained(model_name) | |
#model = AutoModel.from_pretrained(model_name) | |
model_path = hf_hub_download(model_name, | |
filename=model_file, | |
local_dir='./content') | |
print("My model path: ", model_path) | |
llm = Llama(model_path=model_path, | |
n_gpu_layers=-1) | |
def my_inference_function(Question): | |
prompt = f"You are an expert and experienced from the healthcare and biomedical domain with extensive medical knowledge and practical experience. Your name is OpenBioLLM, and you were developed by Saama AI Labs with Open Life Science AI. who's willing to help answer the user's query with explanation. In your explanation, leverage your deep medical expertise such as relevant anatomical structures, physiological processes, diagnostic criteria, treatment guidelines, or other pertinent medical concepts. Use precise medical terminology while still aiming to make the explanation clear and accessible to a general audience. Medical Question: {Question} Medical Answer:" | |
response = llm(prompt, max_tokens=4000)['choices'][0]['text'] | |
return response | |
gradio_interface = gr.ChatInterface(fn = my_inference_function) | |
gradio_interface.launch() | |