asrใฎๆๅญ่ตทใใ็ตๆใ็จใใฆ่ชคๅญใไฟฎๆญฃใใใใใซไฝๆใใใขใใซใงใใ
ไธปใซใใผใฟใปใใๆดๅฝขใซ็นๅใใใใขใใซใงใใ
ใซใผใซใใผในใงใฏใชใ่ชคๅญไฟฎๆญฃใ่กใใใจใใงใใใใจใ็ฎๆใใฆใใพใใ
ไฝฟใๆนใฏไธ่จใณใผใใๅ็ งใใฆใใ ใใใ
# ๅบๅใฎในใณใขใๅซใใฆ็ๆใใ
import os
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
# CUDAใใใคในใฎ่จญๅฎ
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
# ใขใใซใจใใผใฏใใคใถใผใฎใใฃใฌใฏใใช
MODEL_DIRECTORY = ("swdq/ASR-Fixer")
def load_model_and_tokenizer():
tokenizer = AutoTokenizer.from_pretrained(MODEL_DIRECTORY)
model = AutoModelForCausalLM.from_pretrained(
MODEL_DIRECTORY,
device_map="auto",
use_auth_token=True,
torch_dtype=torch.float16,
)
return tokenizer, model
def generate_text(prompt, tokenizer, model):
streamer = TextStreamer(tokenizer, skip_prompt=False)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
# ๅบๅใฎในใณใขใๅซใใฆ็ๆใใ
outputs = model.generate(
input_ids=inputs["input_ids"],
attention_mask=inputs["attention_mask"],
max_new_tokens=500,
min_new_tokens=1,
do_sample=True,
top_k=1,
repetition_penalty=1.0,
temperature=0.1,
use_cache=True,
bos_token_id=tokenizer.bos_token_id,
eos_token_id=tokenizer.eos_token_id,
streamer=streamer,
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
"""ใกใคใณใซใผใ้ขๆฐ"""
tokenizer, model = load_model_and_tokenizer()
text = "ใใใใโฆใใ
ใใโฆใใฎใใกใใกใใชใโฆใกใ
ใฑใใกใ
ใโฆใกใใใจใใใฎ่จใใใจ่ใใพใกใ
ใโฆ"
initial_prompt = f"ASR: {text} ๆญฃ่งฃ: "
generated_text = generate_text(initial_prompt, tokenizer, model)
result = generated_text.split("ๆญฃ่งฃ: ", 1)[-1].strip()
print(text)
print(result)
ไพ(ใใผใฟใปใใใซใชใใใญในใ)
asr ใใใใโฆใใ
ใใโฆใใฎใใกใใกใใชใโฆใกใ
ใฑใใกใ
ใโฆใกใใใจใใใฎ่จใใใจ่ใใพใกใ
ใโฆ
true ใใใใโฆใกใ
ใใโฆใใฎใใกใใกใใชใโฆใกใ
ใฑใใกใ
ใโฆใกใใใจใใใฎ่จใใใจใ่ใใพใกใ
ใโฆ
asr ่งฆใใใใจใดใใฃใจใใๆฐๆใกใใใใใพใใ ใใใใฃใใใใใชโฆๆฐๆใกใใใใใชโฆใใฃโฆ
true ่งฆใใใใจใใดใใฃใจใใๆฐๆใกใใใใใพใใโฆใใใใฃใใใใใชโฆๆฐๆใกใใใใใชโฆใใฃโฆ
asr ใใธใธโฆ็งใฎใๅฃใงใใงใใใฉโฆ ใใฏใฏโฆใฃใฆใใใใฏโฆใใฃใฑใใ็ตๆงๅใฃใกใใฃใฆใพใใใญใใใใ
true ใใธใธโฆ็งใฎใๅฃใงใใงใใใฉโฆใใฏใฏโฆใฃใฆใใใใฏใฏโฆใใฃใฑใใ็ตๆงๅใฃใกใใฃใฆใพใใใญใใใใ
asr ๅใกใใพใใใฃใใใฃใใใใฃใใใฃใใใใฃใใคใฐโฆใใใใใใใใใใใใใใใ!
true ๅใกใใพใใใฃใใใฃใใใใฃใใใใฃใใคใฐโฆใใใใใใใใใใใใใใใใใใใใใใใใใใใใใใ!
asr ใใใใใใใกใใฝๅบใใใใ ใใใๆฌกใฏไพฟๅจใซๅฅใใฆใใใใฃใใทใฃใผใฃใฆใใกใใ
true ใใใใใใใกใใฝๅบใใใใ ใใใๆฌกใฏไพฟๅจใซๅฅใใฆใใใใฃใใใใผใฃใฆใใกใใ
asr ๅบใใฆๅบใใฆใใถใผใกใณๅบใใฆใใใผใใๅบใใฆใ
true ๅบใใฆๅบใใฆใใถใผใกใณๅบใใฆใใถใผใกใณๅบใใฆใ
asr ใใผใใผใใใใผใใ ็ฒพๅญใใพใฃใใใ็ใใใโฆใใฃใฑใ็ใฎ่ถณใซใถใฃใใใฆใใ ใใใ
true ใใผใใผใใใใผใใ
modelใฏLocal-Novel-LLM-project/Vecteus-v1ใsftใง็ฌ่ชใใผใฟใปใใใ็จใใฆ่จ็ทดใใพใใใ
- Downloads last month
- 23