Spaces:
Sleeping
Sleeping
File size: 1,604 Bytes
7adb87c 300cc8d 9adba36 8851723 7adb87c b9f5d20 2579b4d 6c5b639 300cc8d 7b971c7 7adb87c 300cc8d 2579b4d 300cc8d b9f5d20 300cc8d 9adba36 cc31257 2c68df4 5bdffed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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()
|