Quantization made by Richard Erkhov.
This model is used to classify whether a user message is an urgent maternal health-related message.
Given a
list of urgency rules related to maternal health and a user message, this model detects whether the
user message qualifies as an urgent health-related message according to the rules. The model is trained to produce the following
JSON
output as its response:
1{
2 "best_matching_rule": "The rule that best matches with the user message.",
3 "probability": "A probability between 0 and 1 in increments of 0.05 that ANY part of the user message matches one of the urgency rules.",
4 "reason": "The reason for selecting the best matching rule and probability."
5}
Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
Then, copy the snippet from the section that is relevant for your usecase.
1# pip install accelerate
2import torch
3
4from .gemma2_inference_hf import get_completions
5from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerBase
6
7DTYPE = torch.bfloat16
8MODEL_ID = "idinsight/gemma-2-2b-it-ud"
9
10tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, add_eos_token=False)
11tokenizer.pad_token = tokenizer.eos_token
12tokenizer.padding_side = "right"
13
14model = AutoModelForCausalLM.from_pretrained(
15 MODEL_ID, device_map="auto", return_dict=True, torch_dtype=DTYPE
16)
17
18text_generation_params = {
19 "do_sample": True,
20 "eos_token_id": tokenizer.eos_token_id,
21 "max_new_tokens": 1024,
22 "num_return_sequences": 1,
23 "repetition_penalty": 1.1,
24 "temperature": 1e-6,
25 "top_p": 0.9,
26}
27
28response = get_completions(
29 model=model,
30 rules_list=[
31 "NOT URGENT",
32 "Bleeding from the vagina",
33 "Bad tummy pain",
34 "Bad headache that won’t go away",
35 "Changes to vision",
36 "Trouble breathing",
37 "Hot or very cold, and very weak",
38 "Fits or uncontrolled shaking",
39 "Baby moves less",
40 "Fluid from the vagina",
41 "Feeding problems",
42 "Fits or uncontrolled shaking",
43 "Fast, slow or difficult breathing",
44 "Too hot or cold",
45 "Baby’s colour changes",
46 "Vomiting and watery poo",
47 "Infected belly button",
48 "Swollen or infected eyes",
49 "Bulging or sunken soft spot",
50 ],
51 skip_special_tokens_during_decode=False,
52 text_generation_params=text_generation_params,
53 tokenizer=tokenizer,
54 user_message="If my newborn can't able to breathe what can i do",
55)
56print(f"{response = }")
Model evaluation metrics and results on a private test dataset containing 3k samples.
The finetuned Gemma-2 model was evaluated against GPT-3.5-Turbo, GPT-4o-mini, and GPT-4o:
This model has certain limitations that users should be aware of.
This model has been finetuned specifically for the task of determining whether a user message is an urgent or non-urgent maternal-health
related message. As a result, no guarantees are made with respect to model performance for other use cases. Users may use the model to detect
urgency messages for new rule sets and user messages and for research and education purposes.
The development of large language models (LLMs) raises several ethical concerns.
In creating an open model, we have carefully considered the following:
-
Bias and Fairness
- LLMs trained on large-scale, real-world text data can reflect socio-cultural
biases embedded in the training material. These models underwent careful
scrutiny, input data pre-processing described and posterior evaluations
reported in this card.
-
Misinformation and Misuse
- LLMs can be misused to generate text that is false, misleading, or harmful.
- Guidelines are provided for responsible use with the model, see the
Responsible Generative AI Toolkit.
-
Transparency and Accountability:
- This model card summarizes details on the models' architecture,
capabilities, limitations, and evaluation processes.
- A responsibly developed open model offers the opportunity to share
innovation by making LLM technology accessible to developers and researchers
across the AI ecosystem.
Risks identified and mitigations:
-
Perpetuation of biases: It's encouraged to perform continuous monitoring
(using evaluation metrics, human review) and the exploration of de-biasing
techniques during model training, fine-tuning, and other use cases.
-
Generation of harmful content: Mechanisms and guidelines for content safety
are essential. Developers are encouraged to exercise caution and implement
appropriate content safety safeguards based on their specific product policies
and application use cases.
-
Misuse for malicious purposes: Technical limitations and developer and
end-user education can help mitigate against malicious applications of LLMs.
Educational resources and reporting mechanisms for users to flag misuse are
provided. Prohibited uses of Gemma models are outlined in the
Gemma Prohibited Use Policy.
-
Privacy violations: Models were trained on data filtered for removal of PII
(Personally Identifiable Information). Developers are encouraged to adhere to
privacy regulations with privacy-preserving techniques.
For more information regarding this model, its training dataset, and use cases, please contact
Tony Zhao.