File size: 1,040 Bytes
5f8220c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Interactive Refinement Qwen3-14B 使用例
"""

from transformers import AutoTokenizer, AutoModelForCausalLM
import json
import torch

class InteractiveRefinementInference:
    def __init__(self, model_name_or_path):
        self.tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
        self.model = AutoModelForCausalLM.from_pretrained(
            model_name_or_path,
            torch_dtype=torch.float16,
            device_map="auto"
        )
        
        # 設定ファイル読み込み
        with open(f"{model_name_or_path}/refinement_config.json", "r") as f:
            self.config = json.load(f)
    
    def generate(self, question, rounds=None):
        rounds = rounds or self.config["refinement_rounds"]
        # Interactive Refinement実装(詳細は元のコードを参照)
        pass

# 使用例
if __name__ == "__main__":
    model = InteractiveRefinementInference("your-username/interactive-refinement-qwen3-14b")
    response = model.generate("あなたの質問")
    print(response)