Update app.py
Browse files
app.py
CHANGED
@@ -1,52 +1,4 @@
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
-
import os
|
3 |
-
import contextlib
|
4 |
-
|
5 |
-
@contextlib.contextmanager
|
6 |
-
def new_cd(x):
|
7 |
-
d = os.getcwd()
|
8 |
-
|
9 |
-
# This could raise an exception, but it's probably
|
10 |
-
# best to let it propagate and let the caller
|
11 |
-
# deal with it, since they requested x
|
12 |
-
os.chdir(x)
|
13 |
-
|
14 |
-
try:
|
15 |
-
yield
|
16 |
-
|
17 |
-
finally:
|
18 |
-
# This could also raise an exception, but you *really*
|
19 |
-
# aren't equipped to figure out what went wrong if the
|
20 |
-
# old working directory can't be restored.
|
21 |
-
os.chdir(d)
|
22 |
-
from ipex_llm.transformers import AutoModelForCausalLM
|
23 |
-
from transformers import LlamaTokenizer
|
24 |
-
|
25 |
-
|
26 |
-
llm = AutoModelForCausalLM.from_pretrained("checkpoints\\Llama-2-7b-chat-hf",load_in_low_bit="sym_int4")
|
27 |
-
llm.save_low_bit("checkpoints\\Llama-2-7b-chat-hf-INT4")
|
28 |
-
|
29 |
-
tokenizer = LlamaTokenizer.from_pretrained("checkpoints\\Llama-2-7b-chat-hf\\")
|
30 |
-
tokenizer.save_pretrained("checkpoints\\Llama-2-7b-chat-hf-INT4")
|
31 |
-
from huggingface_hub import snapshot_download
|
32 |
-
|
33 |
-
# Clip
|
34 |
-
snapshot_download(repo_id='openai/clip-vit-base-patch32',
|
35 |
-
local_dir="./checkpoints/clip-vit-base-patch32")
|
36 |
-
|
37 |
-
# LLM
|
38 |
-
snapshot_download(repo_id='meta-llama/Llama-2-7b-chat-hf',
|
39 |
-
local_dir="./checkpoints/Llama-2-7b-chat-hf", token=hf_token)
|
40 |
-
|
41 |
-
# Translation
|
42 |
-
snapshot_download(repo_id='Helsinki-NLP/opus-mt-en-zh',
|
43 |
-
local_dir="./checkpoints/Helsinki-NLP-opus-mt-en-zh")
|
44 |
-
snapshot_download(repo_id='Helsinki-NLP/opus-mt-zh-en',
|
45 |
-
local_dir="./checkpoints/Helsinki-NLP-opus-mt-zh-en")
|
46 |
-
|
47 |
-
# Embeddings
|
48 |
-
snapshot_download(repo_id='sentence-transformers/all-MiniLM-L12-v2',
|
49 |
-
local_dir="./checkpoints/all-MiniLM-L12-v2")
|
50 |
import argparse
|
51 |
import gradio as gr
|
52 |
import os
|
|
|
1 |
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import argparse
|
3 |
import gradio as gr
|
4 |
import os
|