Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
print("start to run")
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
-
os.system("pip install torch transformers sentencepiece accelerate")
|
5 |
import torch
|
6 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
7 |
-
|
8 |
# モデルとトークナイザの初期化
|
9 |
|
10 |
model = AutoModelForCausalLM.from_pretrained("cyberagent/open-calm-1b", device_map="auto", torch_dtype=torch.float16)
|
11 |
tokenizer = AutoTokenizer.from_pretrained("cyberagent/open-calm-1b")
|
12 |
-
|
13 |
# 推論用の関数
|
14 |
def generate_text(input_text, max_new_tokens, temperature, top_p, repetition_penalty):
|
15 |
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
|
|
|
1 |
print("start to run")
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
+
os.system("pip install torch transformers sentencepiece accelerate torch.utils torchvision")
|
5 |
import torch
|
6 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
7 |
+
print("[code] All module has imported.")
|
8 |
# モデルとトークナイザの初期化
|
9 |
|
10 |
model = AutoModelForCausalLM.from_pretrained("cyberagent/open-calm-1b", device_map="auto", torch_dtype=torch.float16)
|
11 |
tokenizer = AutoTokenizer.from_pretrained("cyberagent/open-calm-1b")
|
12 |
+
print("[code] model loaded")
|
13 |
# 推論用の関数
|
14 |
def generate_text(input_text, max_new_tokens, temperature, top_p, repetition_penalty):
|
15 |
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
|