Spaces:
Sleeping
Sleeping
Commit
·
6ba7aeb
1
Parent(s):
55f7349
モデルを変えてみた
Browse files- app.py +14 -1
- requirements.txt +3 -1
app.py
CHANGED
@@ -1,23 +1,36 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import pathlib
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
from llama_cpp import Llama
|
|
|
5 |
from sentence_transformers import SentenceTransformer
|
6 |
import faiss
|
7 |
import numpy as np
|
8 |
import pandas as pd
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
## LLMの読み込み
|
11 |
models_dir = pathlib.Path(__file__).parent / "models"
|
12 |
models_dir.mkdir(exist_ok=True)
|
13 |
|
14 |
model_path = hf_hub_download(
|
15 |
-
repo_id="
|
16 |
filename="model.gguf",
|
17 |
local_dir=models_dir
|
18 |
)
|
19 |
|
20 |
llm = Llama(model_path=model_path)
|
|
|
21 |
|
22 |
## 埋め込みモデルの読み込み
|
23 |
model = SentenceTransformer("BAAI/bge-m3")
|
|
|
1 |
import gradio as gr
|
2 |
+
"""
|
3 |
import pathlib
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
from llama_cpp import Llama
|
6 |
+
"""
|
7 |
from sentence_transformers import SentenceTransformer
|
8 |
import faiss
|
9 |
import numpy as np
|
10 |
import pandas as pd
|
11 |
|
12 |
+
## LLMの読み込み(Qwen2.5-3Bをsafetensorsで読み込み)
|
13 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
14 |
+
import torch
|
15 |
+
|
16 |
+
model_name = "Qwen/Qwen2.5-3B"
|
17 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
18 |
+
llm = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, torch_dtype=torch.float16)
|
19 |
+
llm.eval()
|
20 |
+
|
21 |
+
"""
|
22 |
## LLMの読み込み
|
23 |
models_dir = pathlib.Path(__file__).parent / "models"
|
24 |
models_dir.mkdir(exist_ok=True)
|
25 |
|
26 |
model_path = hf_hub_download(
|
27 |
+
repo_id="Mori-kamiyama/sarashina2-13b-r1",
|
28 |
filename="model.gguf",
|
29 |
local_dir=models_dir
|
30 |
)
|
31 |
|
32 |
llm = Llama(model_path=model_path)
|
33 |
+
"""
|
34 |
|
35 |
## 埋め込みモデルの読み込み
|
36 |
model = SentenceTransformer("BAAI/bge-m3")
|
requirements.txt
CHANGED
@@ -5,4 +5,6 @@ pathlib
|
|
5 |
sentence-transformers
|
6 |
faiss-cpu
|
7 |
numpy
|
8 |
-
pandas
|
|
|
|
|
|
5 |
sentence-transformers
|
6 |
faiss-cpu
|
7 |
numpy
|
8 |
+
pandas
|
9 |
+
pytorch
|
10 |
+
transformers
|