Llama3.1-8B-K12KGraph is a full-parameter supervised fine-tuning (SFT) model based on
meta-llama/Llama-3.1-8B.
It was trained on the K12-Train data associated with the
K12-KGraph project for educational question answering.
This repository contains a standalone Transformers checkpoint. The original
Llama-3.1-8B weights do not need to be downloaded separately.
The model is intended for research on K-12 educational question answering,
knowledge-intensive reasoning, and evaluation of models trained with
knowledge-graph-derived educational data.
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "lhpku20010120/llama3.1-8b-k12kgraph"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 dtype=torch.bfloat16,
10 device_map="auto",
11)
12
13messages = [
14 {
15 "role": "user",
16 "content": "Explain the difference between the light-dependent and light-independent reactions in photosynthesis.",
17 }
18]
19
20inputs = tokenizer.apply_chat_template(
21 messages,
22 add_generation_prompt=True,
23 return_tensors="pt",
24).to(model.device)
25
26with torch.inference_mode():
27 outputs = model.generate(
28 inputs,
29 max_new_tokens=512,
30 do_sample=False,
31 )
32
33answer = tokenizer.decode(
34 outputs[0, inputs.shape[-1]:],
35 skip_special_tokens=True,
36)
37print(answer)
Use of this model is subject to the
Llama 3.1 Community License and the Llama 3.1 Acceptable Use Policy. Users are also responsible for complying with the licenses and terms associated with the training data, benchmark data, and generated content. The release of model weights does not grant rights to reproduce any third-party textbook or benchmark material.
Built with Llama. This model is based on Llama 3.1 8B and was trained with LLaMA-Factory. Please cite the Llama 3.1 and K12-KGraph projects when using this checkpoint in research.