Update app.py
Browse files
app.py
CHANGED
@@ -41,21 +41,20 @@ from transformers import (
|
|
41 |
TextIteratorStreamer,
|
42 |
pipeline, AutoTokenizer
|
43 |
)
|
44 |
-
from spaces import GPU
|
45 |
|
46 |
-
@GPU
|
47 |
-
def generate():
|
48 |
-
# Your code here
|
49 |
|
50 |
# 日本語モデルを指定
|
51 |
-
|
52 |
-
model_name = "SakanaAI/EvoLLM-JP-v1-7B" # This line is now correctly indented
|
53 |
# Add more code here, all indented at the same level
|
54 |
# model_name = "SakanaAI/EvoLLM-JP-v1-7B"
|
|
|
55 |
|
|
|
|
|
|
|
56 |
# トークナイザーとパイプラインの設定
|
57 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
58 |
-
generator = pipeline('text-generation', model=model_name, tokenizer=tokenizer, device=-1) # device=0はGPUを使用する設定
|
59 |
|
60 |
def generate_text(prompt, max_length):
|
61 |
result = generator(prompt, max_length=max_length, num_return_sequences=1)
|
|
|
41 |
TextIteratorStreamer,
|
42 |
pipeline, AutoTokenizer
|
43 |
)
|
|
|
44 |
|
|
|
|
|
|
|
45 |
|
46 |
# 日本語モデルを指定
|
47 |
+
model_name = "SakanaAI/EvoLLM-JP-v1-7B" # This line is now correctly indented
|
|
|
48 |
# Add more code here, all indented at the same level
|
49 |
# model_name = "SakanaAI/EvoLLM-JP-v1-7B"
|
50 |
+
from spaces import GPU
|
51 |
|
52 |
+
@GPU
|
53 |
+
def generate():
|
54 |
+
# Your code here
|
55 |
# トークナイザーとパイプラインの設定
|
56 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
57 |
+
generator = pipeline('text-generation', model=model_name, tokenizer=tokenizer, device=-1) # device=0はGPUを使用する設定
|
58 |
|
59 |
def generate_text(prompt, max_length):
|
60 |
result = generator(prompt, max_length=max_length, num_return_sequences=1)
|