File size: 1,679 Bytes
2eee342
4bd0020
 
 
64ef2f3
 
 
 
 
5b2e760
64ef2f3
 
 
 
5b2e760
79fa34a
ab107b4
5b2e760
79fa34a
64ef2f3
 
 
 
 
 
79fa34a
64ef2f3
10a70da
64ef2f3
 
 
 
 
2eee342
4bd0020
10a70da
 
4bd0020
 
 
53426ce
453a9b7
4bd0020
 
5c372d7
7a6783f
53426ce
6c1f2be
 
4bd0020
453a9b7
4bd0020
 
10a70da
4bd0020
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
46
47
48
49
50
51
52
53
54
55
import gradio as gr
import regex as re
from tqdm import tqdm
import pickle
from transformers import (
    AutoModelForCausalLM,
    AutoTokenizer,
    pipeline,
)
import torch

def check_check():

    model_name = "NousResearch/Llama-2-7b-chat-hf"
    
    print('model loading......')
    model = AutoModelForCausalLM.from_pretrained(model_name)

    print("model loaded")
    model.config.use_cache = False
    
    tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
    tokenizer.pad_token = tokenizer.eos_token
    
    file_path = 'data.pkl'
    print("opening file")
    with open(file_path, 'rb') as files:
        model.state_dict = pickle.load(files)
    print("Lets go baby")
        
    # pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=1500)
    # result = pipe(text)
    # print(result[0]['generated_text'])


title = "Fine tuning Llama2-7B"
description = "A simple Gradio interface to do some shit"


def inference(text):

    return "A", "B", "C"

iface = gr.Interface(
    inference,
    inputs=["text"],
    outputs=["text", "text", "text"],
    examples=["سفید رنگ ہیں آخر سیاہ مو کرتے لٹاتے دولت دنیا کو میکدے میں ہم طلائی ساغر مے نقرئی سبو کرتے ہمیشہ میں نے گریباں کو چاک چاک کیا",
              " دل کہ آتے ہیں جس کو دھیان بہت خود بھی آتا ہے اپنے دھیان میں کیاوہ ملے تو یہ پوچھنا ہے مجھےاب بھی ہوں میں تری امان میں کیا"],
    title = title,
    description = description
)

check_check()
iface.launch()