aleynahukmet commited on
Commit
3c7a0f6
1 Parent(s): 276ef5d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +82 -0
README.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: unsloth/gemma-2-2b-it
3
+ library_name: peft
4
+ ---
5
+
6
+ ## Model Summary
7
+
8
+ This model is fine-tuned from gemma-2-2b-it using a custom dataset created by our team, providing a concise overview of its key details and purpose.
9
+
10
+
11
+ ## Motivation
12
+
13
+ Women's health is a critical and often underserved topic, with limited accessible resources where women can ask questions and receive reliable answers about their health. Recognizing this gap, we embarked on this project to develop a compact language model (LLM) tailored to address these needs. Our goal is to create a model that not only provides valuable insights but also enables efficient on-device inference, ensuring greater accessibility and usability for women worldwide.
14
+
15
+
16
+ ## Usage
17
+
18
+ ```python
19
+
20
+ from unsloth import FastLanguageModel
21
+ import torch
22
+ from transformers import TextStreamer
23
+
24
+
25
+ max_seq_length = 2048
26
+ dtype = None
27
+ load_in_4bit = False
28
+ lora_path = "altaidevorg/gemma-women-health-checkpoint-1292"
29
+ use_streamer = False
30
+
31
+ model, tokenizer = FastLanguageModel.from_pretrained(
32
+ lora_path,
33
+ max_seq_length=max_seq_length,
34
+ dtype=dtype,
35
+ load_in_4bit=load_in_4bit,
36
+ )
37
+ FastLanguageModel.for_inference(model)
38
+
39
+ text_streamer = TextStreamer(tokenizer, skip_prompt = True)
40
+
41
+
42
+ messages = [
43
+ {"role": "user", "content": user_prompt},
44
+ ]
45
+
46
+
47
+ input_ids = tokenizer.apply_chat_template(
48
+ messages,
49
+ tokenize = True,
50
+ add_generation_prompt = True,
51
+ return_tensors = "pt",
52
+ ).cuda()
53
+
54
+ terminators = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<end_of_turn>")]
55
+
56
+ outputs = model.generate(input_ids = input_ids,
57
+ streamer = text_streamer if use_streamer else None,
58
+ max_new_tokens = 1024,
59
+ eos_token_id=terminators,
60
+ use_cache=True, do_sample=True, temperature=0.6, top_p=0.9)
61
+ if not use_streamer:
62
+ out = outputs[0][input_ids.shape[-1]:]
63
+ generated_text = tokenizer.decode(out, skip_special_tokens=True)
64
+ print(generated_text)
65
+
66
+
67
+ ```
68
+
69
+
70
+ ## Dataset
71
+
72
+ The dataset was prepared through a comprehensive process based on our synthetic dataset generation method. Health-related websites were scraped, open-source e-books and PDFs focusing on women's health were collected, and an instruction dataset was created from these sources. To generate high-quality questions, we utilized a technique that involves role-playing between two LLMs and contextually-augmented by RAG.
73
+ The dataset will be made publicly available through its dedicated repository [altaidevorg/women-health-mini](https://huggingface.co/datasets/altaidevorg/women-health-mini). Additionally, the code used for dataset generation will be released in the future to promote transparency and enable reproducibility.
74
+
75
+ ## Evaluation Notes
76
+
77
+ During testing, we observed that the LoRA checkpoint performed better in evaluations compared to the version where the LoRA checkpoint was [merged with the base model](https://huggingface.co/altaidevorg/gemma-women-health-merged). Interestingly, the standalone LoRA checkpoint consistently delivered superior results, though we currently lack a concrete explanation for this phenomenon.
78
+ We are actively investigating the underlying cause, with our best hypothesis being that the merging process may introduce some form of precision loss. Further research is underway to validate this theory and optimize the performance.
79
+
80
+ ### Disclaimer
81
+
82
+ Any output of this model should never be taken as a medical advice, and it is mainly intended for research purposes.