kingabzpro commited on
Commit
023b9ee
·
verified ·
1 Parent(s): ee2f9c5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -29
README.md CHANGED
@@ -17,50 +17,40 @@ pipeline_tag: text-generation
17
 
18
  # Model Card for gpt-oss-20b-medical-qa
19
 
20
- This model is a fine-tuned version of [openai/gpt-oss-20b](https://huggingface.co/openai/gpt-oss-20b) on the [kingabzpro/gpt-oss-20b-medical-qa](https://huggingface.co/datasets/kingabzpro/gpt-oss-20b-medical-qa) dataset.
21
  It has been trained using [TRL](https://github.com/huggingface/trl).
22
 
23
  ## Quick start
24
 
25
  ```python
26
- from transformers import AutoModelForCausalLM, AutoTokenizer
27
- from peft import PeftModel
28
 
29
- # Load the tokenizer
30
- tokenizer = AutoTokenizer.from_pretrained("openai/gpt-oss-20b")
31
 
32
- # Load the original model first
33
- model_kwargs = dict(attn_implementation="eager", torch_dtype="auto", use_cache=True, device_map="auto")
34
- base_model = AutoModelForCausalLM.from_pretrained("openai/gpt-oss-20b", **model_kwargs).cuda()
35
 
36
- # Merge fine-tuned weights with the base model
37
- peft_model_id = "kingabzpro/gpt-oss-20b-medical-qa"
38
- model = PeftModel.from_pretrained(base_model, peft_model_id)
39
- model = model.merge_and_unload()
40
-
41
- question = dataset[0]["Open-ended Verifiable Question"]
42
 
43
- text = render_infernce_harmony(question)
44
 
45
- inputs = tokenizer(
46
- [text + tokenizer.eos_token], return_tensors="pt"
47
- ).to("cuda")
48
- outputs = model.generate(
49
- input_ids=inputs.input_ids,
50
- attention_mask=inputs.attention_mask,
51
  max_new_tokens=20,
52
- eos_token_id=tokenizer.eos_token_id,
53
- use_cache=True,
54
- )
55
- response = tokenizer.batch_decode(outputs)
56
- print(response[0])
57
  ```
58
  Output:
59
 
60
  ```bash
61
- <|start|>developer<|message|># Instructions
62
-
63
- You are a medical expert with advanced knowledge in clinical reasoning and diagnostics. Respond with ONLY the final diagnosis/cause in ≤5 words.<|end|><|start|>user<|message|>An 88-year-old woman with osteoarthritis is experiencing mild epigastric discomfort and has vomited material resembling coffee grounds multiple times. Considering her use of naproxen, what is the most likely cause of her gastrointestinal blood loss?<|end|><|start|>assistant<|return|><|message|>Stomach ulcer<|end|><|return|>
64
  ```
65
  ## Training procedure
66
  This model was trained with SFT.
 
17
 
18
  # Model Card for gpt-oss-20b-medical-qa
19
 
20
+ This model is a fine-tuned version of [openai/gpt-oss-20b](https://huggingface.co/openai/gpt-oss-20b) on the [FreedomIntelligence/medical-o1-verifiable-problem](https://huggingface.co/datasets/FreedomIntelligence/medical-o1-verifiable-problem) dataset.
21
  It has been trained using [TRL](https://github.com/huggingface/trl).
22
 
23
  ## Quick start
24
 
25
  ```python
26
+ from transformers import pipeline
 
27
 
28
+ prompt = """<|start|>developer<|message|># Instructions
 
29
 
30
+ You are a medical expert with advanced knowledge in clinical reasoning and diagnostics. Respond with ONLY the final diagnosis/cause in ≤5 words.<|end|><|start|>user<|message|>An 88-year-old woman with osteoarthritis is experiencing mild epigastric discomfort and has vomited material resembling coffee grounds multiple times. Considering her use of naproxen, what is the most likely cause of her gastrointestinal blood loss?<|end|><|start|>assistant<|message|>"""
 
 
31
 
32
+ # Load pipeline
33
+ generator = pipeline(
34
+ "text-generation",
35
+ model="kingabzpro/gpt-oss-20b-medical-qa",
36
+ device="cuda" # or device=0
37
+ )
38
 
 
39
 
40
+ # Run inference (passing in chat-style format)
41
+ output = generator(
42
+ prompt,
 
 
 
43
  max_new_tokens=20,
44
+ return_full_text=False
45
+ )[0]
46
+
47
+ print(output["generated_text"])
48
+
49
  ```
50
  Output:
51
 
52
  ```bash
53
+ NSAID use
 
 
54
  ```
55
  ## Training procedure
56
  This model was trained with SFT.