Downloads · 30 days
0
eyepyon/constitution-gemma2-test
constitution-gemma2-test is a text generation model from eyepyon. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
このモデルは、google/gemma-2-2b をベースに憲法教育データでファインチューニングされた専門モデルです。
Downloads · 30 days
0
Access
Public
Updated Jun 4, 2025
Repo size
117 MB
Likes
0
Public
Click a slice to open those files.
.safetensors83.1 MB · 71%
From the Hugging Face model README
このモデルは、google/gemma-2-2b をベースに憲法教育データでファインチューニングされた専門モデルです。
このモデルは以下の教育シーンで活用できます:
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# ベースモデルとトークナイザーを読み込み
base_model = AutoModelForCausalLM.from_pretrained(
"google/gemma-2-2b",
torch_dtype="auto",
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b")
# LoRAアダプターを適用
model = PeftModel.from_pretrained(base_model, "eyepyon/constitution-gemma2-test")
# 憲法問題の解答
def solve_constitution_problem(context, question):
input_text = f"### 法律分野: 憲法\n### コンテキスト:\n{context}\n\n### 問題:\n{question}\n\n### 解答:\n"
inputs = tokenizer(input_text, return_tensors="pt")
if torch.cuda.is_available():
inputs = {k: v.to(model.device) for k, v in inputs.items()}
with torch.no_grad():
outputs = model.generate(
**inputs,
max_length=1024,
do_sample=True,
temperature=0.3, # 法律問題では低めの温度
top_p=0.8,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
if "### 解答:" in response:
response = response.split("### 解答:")[-1].strip()
return response
# 使用例
context = "憲法に関する法律問題について、見解の関係性を分析し、批判の有無を判断してください。"
question = "人権の享有主体に関する次の記述について、bの見解がaの見解の批判となっているか分析してください..."
answer = solve_constitution_problem(context, question)
print(answer)
### 法律分野: 憲法
### コンテキスト:
[法的背景や問題設定]
### 問題:
[具体的な憲法問題]
### 解答:
[期待される解答や分析]
Apache 2.0 License
最終更新: 2025年06月04日
このモデルは教育研究目的での使用を想定しています。実際の法的判断には使用せず、必ず専門家の助言を求めてください。