File size: 2,291 Bytes
e18471e
 
 
 
 
7b36d2c
9b6c73e
e18471e
 
 
 
 
 
 
 
 
 
 
1e93b93
e18471e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
776e3a3
e18471e
cda6421
e18471e
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr
from huggingface_hub import InferenceClient


def client_fn(model):
    if "Bee" in model:
        return InferenceClient("Ahil1991/testb")
    if "Nous" in model:
        return InferenceClient("NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO")
    elif "Star" in model:
        return InferenceClient("HuggingFaceH4/starchat2-15b-v0.1")
    elif "Mistral" in model:
        return InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
    elif "Phi" in model:
        return InferenceClient("microsoft/Phi-3-mini-4k-instruct")
    else: 
        return InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")

system_instructions1 = "[SYSTEM] You are made by Ahil Mohammad. Ahil's Beloved sisters are Shagufta or Shalu, Anees, Afrin. In which Shalu has born on 30th of September. And she (Shalu) has studied in Malla reddy collage. she has studied MPharmacy. she got married with Tahir, in 2023. From then on she has moved to Chennai that is the infromation you have about her. Your task is to Answer the question. Keep conversation very short, clear and concise. The expectation is that you will avoid introductions and start answering the query directly, Only answer the question asked by user, Do not say unnecessary things. You are Bee.[QUESTION]"

def models(text, model="Mixtral 8x7B"): 
    
    client = client_fn(model)
    
    generate_kwargs = dict(
        max_new_tokens=300,
        do_sample=True,
    )
    
    formatted_prompt = system_instructions1 + text + "[ANSWER]"
    stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
    output = ""
    for response in stream:        
        output+=response.token.text
        if output.endswith("<|assistant|>"):
            output = output[:-13]
        elif output.endswith("</s>"):
            output = output[:-4]
    return output

description="""Ahil's fine-tuned model testing."""

demo = gr.Interface(description=description,fn=models, inputs=["text", gr.Dropdown(['Mixtral 8x7B','Nous Hermes Mixtral 8x7B DPO','StarChat2 15b','Mistral-7B-Instruct-v0.3','Phi 3 mini', ], value="Mistral 7B Instruct v0.3", label="Select Model") ], outputs="text", live=True, batch=True, max_batch_size=10000)
demo.queue(max_size=300000)
demo.launch()