Downloads · 30 days
0
tora2024/llm-jp-3-13b-finetune
llm-jp-3-13b-finetune is a machine learning model from tora2024. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This is the model that was made to solve Japanese tasks. It was fine-tuned by the data consisting of Japanese. llmのための日本語インストラクションデータ作成 is the data. In detail,ichikawa-instruction-003-001-1, ichikara-instruction-003-0…
Downloads · 30 days
0
Access
Public
Updated Dec 17, 2024
Repo size
501 MB
Likes
0
Public
Click a slice to open those files.
.safetensors250 MB · 97%
From the Hugging Face model README
This is the model that was made to solve Japanese tasks. It was fine-tuned by the data consisting of Japanese. llmのための日本語インストラクションデータ作成 is the data. In detail,ichikawa-instruction-003-001-1, ichikara-instruction-003-001-2.1.json, ichikara-instruction-003-001-2.2.json, ichikara-instruction-003-001-5.1.json, ichikara-instruction-003-001-5.2.json are the data In addition, this model has a following RAG function
MAX_TOKENS = 512
def classify_query(input_text): """クエリを分類して適切な指示を返す""" if "理由" in input_text: return "理由を順序だてて述べてください" elif "方法" in input_text: return "手順を具体的に説明してください" else: return "簡潔かつ正確に説明してください"
def postprocess_output(output_text): """生成された出力の後処理""" processed = re.sub(r"不要なフレーズ|テンプレート文", "", output_text) return processed.strip()
results = [] for data in tqdm(datasets): input_text = data["input"] instruction = classify_query(input_text)
prompt = f"""### 指示 ({instruction})(正しいことのみを語れ)
{input_text}
### 回答
"""
try:
tokenized_input = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt").to(model.device)
if tokenized_input.size(1) > MAX_TOKENS:
tokenized_input = tokenized_input[:, :MAX_TOKENS]
attention_mask = torch.ones_like(tokenized_input)
with torch.no_grad():
outputs = model.generate(
tokenized_input,
attention_mask=attention_mask,
max_new_tokens=100,
do_sample=False,
repetition_penalty=1.2,
pad_token_id=tokenizer.eos_token_id
)[0]
output = tokenizer.decode(outputs[tokenized_input.size(1):], skip_special_tokens=True)
output = postprocess_output(output)
results.append({"task_id": data["task_id"], "input": input_text, "output": output})
logging.info(f"Task {data['task_id']} completed successfully.")
except Exception as e:
logging.error(f"Error for task_id {data['task_id']}: {str(e)}")
results.append({"task_id": data["task_id"], "input": input_text, "output": f"Error: {str(e)}"})
jsonl_id = "example_model_id" # モデルIDを指定 with open(f"./{jsonl_id}-outputs.jsonl", 'w', encoding='utf-8') as f: for result in results: filtered_result = {key: result[key] for key in ["task_id", "output"] if key in result} json.dump(filtered_result, f, ensure_ascii=False) f.write('\n')
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]