初始化项目,由ModelHub XC社区提供模型
Model: HiTZ/Marmoka-es-Llama-3.1-8B-Instruct Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
233
README.md
Normal file
233
README.md
Normal file
@@ -0,0 +1,233 @@
|
||||
---
|
||||
license: apache-2.0
|
||||
language:
|
||||
- es
|
||||
base_model: meta-llama/Llama-3.1-8B-Instruct
|
||||
library_name: transformers
|
||||
pipeline_tag: text-generation
|
||||
datasets:
|
||||
- HiTZ/Magpie-Llama-3.1-70B-Instruct-Filtered
|
||||
tags:
|
||||
- biomedical
|
||||
- medical
|
||||
- clinical
|
||||
- spanish
|
||||
- llama-3.1
|
||||
- continual-pretraining
|
||||
- merge
|
||||
widget:
|
||||
- messages:
|
||||
- role: user
|
||||
content: >-
|
||||
Varón de 55 años con dolor torácico opresivo irradiado al brazo izquierdo.
|
||||
¿Cuál es la prueba diagnóstica inicial más adecuada?
|
||||
|
||||
A) Radiografía de tórax
|
||||
|
||||
B) Electrocardiograma de 12 derivaciones
|
||||
|
||||
C) Ecografía abdominal
|
||||
|
||||
D) Espirometría
|
||||
|
||||
Responde solo con la letra de la opción correcta.
|
||||
- messages:
|
||||
- role: user
|
||||
content: Explica el mecanismo de acción de la metformina en la diabetes tipo 2.
|
||||
- messages:
|
||||
- role: user
|
||||
content: >-
|
||||
¿Cuáles son los efectos adversos más frecuentes de los inhibidores de la
|
||||
ECA?
|
||||
---
|
||||
|
||||
|
||||
<br>
|
||||
<div style="text-align: center;">
|
||||
<img src="https://cdn-uploads.huggingface.co/production/uploads/6560b3ac1338610184656ce0/RrEa7YIiH9kV4SdEwa1ub.png" style="height: 175px;display: block;margin-left: auto;margin-right: auto;">
|
||||
</div>
|
||||
|
||||
<h1 style="text-align: center;">
|
||||
<b>Marmoka-es</b>
|
||||
<br>
|
||||
A Lightweight Spanish Clinical Large Language Model
|
||||
<br>
|
||||
Built on Llama 3.1
|
||||
</h1>
|
||||
|
||||
<br>
|
||||
|
||||
<p style="text-align: justify;">
|
||||
Marmoka is a family of lightweight 8B-parameter clinical LLMs for English and Spanish. Marmoka-es is a Spanish member of the family, developed to address the scarcity of high-quality medical data and instructions in Spanish. It was developed through continual domain-adaptive pretraining (DAPT) of Llama-3.1-8B-Instruct on Spanish medical corpora, mixed with general-domain instructions to preserve its instruction-following ability. Marmoka-es consistently outperforms both Llama-3.1-8B-Instruct and Llama3.1-Aloe-Beta-8B on Spanish clinical multiple-choice QA, showing that robust medical LLMs can be developed for languages that remain low-resource in the medical domain.
|
||||
</p>
|
||||
|
||||
- 📖 Paper: [To Adapt or not to Adapt, Rethinking the Value of Medical Knowledge-Aware Large Language Models](https://arxiv.org/abs/2604.06854)
|
||||
|
||||
|
||||
## How to Get Started with the Model
|
||||
|
||||
You can use the model with the `transformers` pipeline (it uses the Llama 3.1 chat template):
|
||||
```python
|
||||
import torch
|
||||
from transformers import pipeline
|
||||
|
||||
pipe = pipeline(
|
||||
"text-generation",
|
||||
model="HiTZ/Marmoka-es-Llama-3.1-8B-Instruct",
|
||||
torch_dtype=torch.bfloat16,
|
||||
device_map="auto",
|
||||
)
|
||||
|
||||
messages = [
|
||||
{"role": "system", "content": "Eres un experto médico. Responde a la pregunta de opción múltiple únicamente con la letra de la opción correcta."},
|
||||
{"role": "user", "content": "¿Qué déficit vitamínico causa el escorbuto?\nA) Vitamina A\nB) Vitamina B12\nC) Vitamina C\nD) Vitamina D"},
|
||||
]
|
||||
|
||||
outputs = pipe(messages, max_new_tokens=256)
|
||||
print(outputs[0]["generated_text"][-1]["content"])
|
||||
```
|
||||
|
||||
|
||||
# Model Description
|
||||
|
||||
- **Developed by**: Ane G. Domingo-Aldama, Iker De La Iglesia, Maitane Urruela, Aitziber Atutxa, and Ander Barrena
|
||||
- **Contact**: [Ane G. Domingo-Aldama](mailto:ane.garciad@ehu.eus) and [Iker De La Iglesia](mailto:iker.delaiglesia@ehu.eus)
|
||||
- **Language(s) (NLP)**: Spanish
|
||||
- **License**: apache-2.0
|
||||
- **Funding**:
|
||||
- The Spanish Ministry of Science, Innovation and Universities, MCIN/AEI/10.13039/501100011033 projects:
|
||||
- EDHIA PID2022-136522OB-C22 (also supported by FEDER, UE).
|
||||
- TRUST-MED PID2025-174880OB-I00 (also supported by FEDER, UE).
|
||||
- DeepR3 TED2021-130295B-C31 (also supported by the European Union NextGenerationEU/PRTR).
|
||||
- Basque Government:
|
||||
- Research group funding IT1570-22.
|
||||
- HiTZ Center.
|
||||
- Predoctoral grants: FPU23/03347 (I. De La Iglesia, Spanish Ministry of Science, Innovation and Universities), PRE_2024_1_0224 (A. G. Domingo-Aldama) and PRE_2025_1_0177 (M. Urruela), Basque Government.
|
||||
|
||||
|
||||
## Model Details
|
||||
|
||||
<table style="border: 1px; border-collapse: collapse;">
|
||||
<caption>Training settings for Marmoka-es.</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Param. no.</td>
|
||||
<td>~8B</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Architecture</td>
|
||||
<td>Llama 3.1 (decoder-only)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Base model</td>
|
||||
<td><a href="https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct">Llama-3.1-8B-Instruct</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Adaptation</td>
|
||||
<td>DAPT on medical corpora + general-domain instructions</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Medical corpus</td>
|
||||
<td>~908M (≈1B) words (Spanish)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>General instructions</td>
|
||||
<td>310K (Spanish, Magpie)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Marmoka-es training</td>
|
||||
<td>3 models trained with different hyperparameters on the same corpus, merged</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Training framework</td>
|
||||
<td><a href="https://github.com/axolotl-ai-cloud/axolotl">Axolotl</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Merging tool</td>
|
||||
<td><a href="https://github.com/arcee-ai/mergekit">MergeKit</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Model selection</td>
|
||||
<td>Casimedicos validation set (EN & ES)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Training Data
|
||||
|
||||
<p style="text-align: justify;">
|
||||
Marmoka-es was trained with the hybrid strategy of Sainz et al. (2025), which combines continual domain-adaptive pretraining on medical corpora with general-domain instructions to avoid catastrophic forgetting. Unlike traditional DAPT setups, an instruction-tuned model (Llama-3.1-8B-Instruct), rather than a base model, was used as the starting point. Note that this setup includes medical corpora but no dedicated medical instructions; the amount of medical content in the Magpie instructions is minimal. The medical corpora are an updated version of those gathered in De la Iglesia et al. (2025), and were processed and deduplicated using standard approaches (<a href="https://github.com/Maits27/Deduplication">deduplication code</a>).
|
||||
</p>
|
||||
|
||||
<table style="border: 1px; border-collapse: collapse;">
|
||||
<caption>Data sources and sizes used to train Marmoka-es.</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Source</th>
|
||||
<th>Size</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="5">Medical corpora (Spanish)</td>
|
||||
<td>WikiMed</td>
|
||||
<td>16.3M words</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PubMed</td>
|
||||
<td>5.5M words</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Medical Crawler</td>
|
||||
<td>850.7M words</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MeSpEn</td>
|
||||
<td>6.9M words</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SciELO</td>
|
||||
<td>29M words</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>General-domain instructions</td>
|
||||
<td><a href="https://huggingface.co/datasets/HiTZ/Magpie-Llama-3.1-70B-Instruct-Filtered">Magpie (Llama-3.1-70B-Instruct)</a></td>
|
||||
<td>310K instructions</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
# Limitation and Bias
|
||||
|
||||
<p style="text-align: justify;">Marmoka-es is intended for research purposes. Its evaluation is based on short-form multiple-choice question answering with automated accuracy metrics and without expert clinical adjudication, so the validity of the model's underlying reasoning has not been verified, and these benchmarks may not fully capture genuine medical expertise. It is recommended to validate and test the model for specific applications before using it.</p>
|
||||
|
||||
<p style="text-align: justify;">Instruction following and strict output formatting remain a limitation, especially in multi-step tasks such as summarization, where formatting failures were observed. Outputs should be checked whenever a strict format is required.</p>
|
||||
|
||||
## Biases
|
||||
|
||||
<ul>
|
||||
<li><strong>Data Collection Bias:</strong> The training data for Marmoka-es was sourced from the web and open datasets, and may not adequately capture the full range of linguistic, demographic, or clinical variability found in real-world medical settings. This may introduce selection bias, and the model might reflect and propagate these biases in its outputs.</li>
|
||||
<li><strong>Demographic and Linguistic Bias:</strong> Since the training data may not equally represent all demographic groups or linguistic nuances, the model may perform unequally across populations, potentially reinforcing existing health disparities and societal biases.</li>
|
||||
<li><strong>Unexamined Ethical Considerations:</strong> No further assessments have been conducted to determine whether the training data contains biases or personally identifiable information, nor have the anonymization measures been independently verified. All data sources were previously processed, publicly released, and made available with stated limitations, including steps taken to ensure data quality and privacy compliance.</li>
|
||||
</ul>
|
||||
|
||||
## Disclaimer
|
||||
<p>Marmoka-es is intended for research purposes and is not approved for clinical use. It must not be used as a medical device or relied upon for diagnostic or therapeutic decision-making, and its outputs should not be interpreted as medical advice. Using the model without rigorous validation poses significant risks, including misinformation, misclassification, and potential harm.</p>
|
||||
<p>When employed in actual clinical scenarios, all outputs must be independently reviewed and validated by qualified healthcare professionals. We do not take any liability for the use of this model.</p>
|
||||
|
||||
|
||||
# Citing information
|
||||
|
||||
```bibtex
|
||||
@article{domingo2026adapt,
|
||||
title={To Adapt or not to Adapt, Rethinking the Value of Medical Knowledge-Aware Large Language Models},
|
||||
author={Domingo-Aldama, Ane G and De La Iglesia, Iker and Urruela, Maitane and Atutxa, Aitziber and Barrena, Ander},
|
||||
journal={arXiv preprint arXiv:2604.06854},
|
||||
year={2026}
|
||||
}
|
||||
```
|
||||
40
config.json
Normal file
40
config.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"_name_or_path": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"architectures": [
|
||||
"LlamaForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 128000,
|
||||
"eos_token_id": [
|
||||
128001,
|
||||
128008,
|
||||
128009
|
||||
],
|
||||
"head_dim": 128,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 4096,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 14336,
|
||||
"max_position_embeddings": 131072,
|
||||
"mlp_bias": false,
|
||||
"model_type": "llama",
|
||||
"num_attention_heads": 32,
|
||||
"num_hidden_layers": 32,
|
||||
"num_key_value_heads": 8,
|
||||
"pretraining_tp": 1,
|
||||
"rms_norm_eps": 1e-05,
|
||||
"rope_scaling": {
|
||||
"factor": 8.0,
|
||||
"high_freq_factor": 4.0,
|
||||
"low_freq_factor": 1.0,
|
||||
"original_max_position_embeddings": 8192,
|
||||
"rope_type": "llama3"
|
||||
},
|
||||
"rope_theta": 500000.0,
|
||||
"tie_word_embeddings": false,
|
||||
"torch_dtype": "bfloat16",
|
||||
"transformers_version": "4.49.0",
|
||||
"use_cache": true,
|
||||
"vocab_size": 128256
|
||||
}
|
||||
17
mergekit_config.yml
Normal file
17
mergekit_config.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
models:
|
||||
- model: meta-llama/Llama-3.1-8B-Instruct
|
||||
- model: /data/abarrena/mn5/marmoka-es0-mn5ep3_v1.1
|
||||
parameters:
|
||||
density: 0.8
|
||||
weight: 0.2
|
||||
- model: /data/abarrena/mn5/marmoka-es1-mn5ep3_v1.1
|
||||
parameters:
|
||||
density: 0.8
|
||||
weight: 0.6
|
||||
- model: /data/abarrena/mn5/marmoka-es2-mn5ep3_v1.1
|
||||
parameters:
|
||||
density: 0.8
|
||||
weight: 0.2
|
||||
merge_method: dare_ties
|
||||
base_model: meta-llama/Llama-3.1-8B-Instruct
|
||||
dtype: bfloat16
|
||||
3
model-00001-of-00004.safetensors
Normal file
3
model-00001-of-00004.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b6a3ac24ec10f10d04dd19458a04bf1c36fab99d9038697c7d4e4e0db40a7887
|
||||
size 4953586384
|
||||
3
model-00002-of-00004.safetensors
Normal file
3
model-00002-of-00004.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7d27544037f72c89038674cf21cf226ddb86d9ac584725440ecf6c0e87126e09
|
||||
size 4999819336
|
||||
3
model-00003-of-00004.safetensors
Normal file
3
model-00003-of-00004.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:956acbae9220904d29bbd004961f6b1f22d442d527793b18b5b4fe5368745c9b
|
||||
size 4915916144
|
||||
3
model-00004-of-00004.safetensors
Normal file
3
model-00004-of-00004.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d15c2e25e85f738c440a486eaefeb5f1635ea77259dc365e540b45b37cdb52a0
|
||||
size 1191234472
|
||||
1
model.safetensors.index.json
Normal file
1
model.safetensors.index.json
Normal file
File diff suppressed because one or more lines are too long
16
special_tokens_map.json
Normal file
16
special_tokens_map.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"bos_token": {
|
||||
"content": "<|begin_of_text|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"eos_token": {
|
||||
"content": "<|eot_id|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
BIN
tokenizer.json
(Stored with Git LFS)
Normal file
BIN
tokenizer.json
(Stored with Git LFS)
Normal file
Binary file not shown.
2063
tokenizer_config.json
Normal file
2063
tokenizer_config.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user