PEFT
Safetensors
English

Improve model card: Add pipeline tag, correct library_name, expand details, usage, and training info

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +105 -127
README.md CHANGED
@@ -1,45 +1,45 @@
1
  ---
2
  base_model: meta-llama/Llama-3.1-8B
3
- library_name: peft
4
  datasets:
5
  - baartmar/nsm_dataset
6
- license: cc-by-nc-sa-4.0
7
  language:
8
  - en
 
 
 
 
 
 
 
 
9
  ---
10
 
11
- # Model Card for Model ID
12
-
13
- <!-- Provide a quick summary of what the model is/does. -->
14
- A fine-tuned LLM for paraphrasing word-meanings using the natural semantic primes.
15
 
 
16
 
17
  ## Model Details
18
 
19
  ### Model Description
20
 
21
- <!-- Provide a longer summary of what this model is. -->
22
- A fine-tuned LLM for paraphrasing word-meanings using the natural semantic primes.
23
-
24
 
25
- - **Developed by:**
26
- - **Model type:** Text Generation
27
- - **Language(s) (NLP):** English
28
- - **License:** cc-by-nc-sa-4.0
29
- - **Finetuned from model:** Llama-3.1-8B
30
 
31
- ### Model Sources [optional]
32
 
33
- <!-- Provide the basic links for the model. -->
34
-
35
- - **Repository:** https://github.com/OSU-STARLAB/DeepNSM
36
- - **Paper:** https://arxiv.org/abs/2505.11764
37
 
38
  ## Uses
39
 
40
  ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
  To use the DeepNSM model to generate an NSM paraphrase of a word-meaning, you should structure your prompts in the following format:
44
  ```
45
  Word: dangerous
@@ -49,160 +49,138 @@ walking outside at night is dangerous
49
  Paraphrase:
50
  ```
51
 
52
- ### Downstream Use [optional]
53
-
54
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
55
 
56
- [More Information Needed]
57
 
58
  ### Out-of-Scope Use
59
 
60
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
61
-
62
- [More Information Needed]
63
 
64
  ## Bias, Risks, and Limitations
65
 
66
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
67
-
68
- [More Information Needed]
 
69
 
70
  ### Recommendations
71
 
72
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
73
-
74
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
75
 
76
  ## How to Get Started with the Model
77
 
78
- Use the code below to get started with the model.
79
 
80
- [More Information Needed]
 
 
81
 
82
- ## Training Details
83
 
84
- ### Training Data
 
 
 
 
 
 
85
 
86
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
 
87
 
88
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
- ### Training Procedure
91
 
92
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
93
 
94
- #### Preprocessing [optional]
95
 
96
- [More Information Needed]
97
 
 
98
 
99
  #### Training Hyperparameters
100
 
101
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
102
-
103
- #### Speeds, Sizes, Times [optional]
 
 
 
 
 
104
 
105
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
106
 
107
- [More Information Needed]
 
 
108
 
109
  ## Evaluation
110
 
111
- <!-- This section describes the evaluation protocols and provides the results. -->
112
 
113
  ### Testing Data, Factors & Metrics
114
 
115
  #### Testing Data
116
 
117
- <!-- This should link to a Dataset Card if possible. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Factors
122
-
123
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
124
-
125
- [More Information Needed]
126
 
127
  #### Metrics
128
 
129
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
130
-
131
- [More Information Needed]
132
 
133
  ### Results
134
 
135
- [More Information Needed]
136
-
137
- #### Summary
138
-
139
-
140
 
141
- ## Model Examination [optional]
142
 
143
- <!-- Relevant interpretability work for the model goes here -->
144
 
145
- [More Information Needed]
146
-
147
- ## Environmental Impact
148
-
149
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
150
-
151
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
152
-
153
- - **Hardware Type:** [More Information Needed]
154
- - **Hours used:** [More Information Needed]
155
- - **Cloud Provider:** [More Information Needed]
156
- - **Compute Region:** [More Information Needed]
157
- - **Carbon Emitted:** [More Information Needed]
158
-
159
- ## Technical Specifications [optional]
160
-
161
- ### Model Architecture and Objective
162
-
163
- [More Information Needed]
164
-
165
- ### Compute Infrastructure
166
-
167
- [More Information Needed]
168
-
169
- #### Hardware
170
-
171
- [More Information Needed]
172
-
173
- #### Software
174
-
175
- [More Information Needed]
176
-
177
- ## Citation [optional]
178
-
179
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
180
-
181
- **BibTeX:**
182
-
183
- [More Information Needed]
184
-
185
- **APA:**
186
-
187
- [More Information Needed]
188
-
189
- ## Glossary [optional]
190
-
191
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
192
-
193
- [More Information Needed]
194
-
195
- ## More Information [optional]
196
-
197
- [More Information Needed]
198
-
199
- ## Model Card Authors [optional]
200
-
201
- [More Information Needed]
202
 
203
  ## Model Card Contact
204
 
205
- [More Information Needed]
 
206
  ### Framework versions
207
 
208
- - PEFT 0.15.2
 
 
1
  ---
2
  base_model: meta-llama/Llama-3.1-8B
 
3
  datasets:
4
  - baartmar/nsm_dataset
 
5
  language:
6
  - en
7
+ library_name: transformers
8
+ license: cc-by-nc-sa-4.0
9
+ pipeline_tag: text-generation
10
+ tags:
11
+ - nlp
12
+ - paraphrase
13
+ - semantic-analysis
14
+ - llama
15
  ---
16
 
17
+ # Model Card for DeepNSM-8B
 
 
 
18
 
19
+ A fine-tuned Large Language Model (LLM) for paraphrasing word-meanings into Natural Semantic Metalanguage (NSM) explications, presented in the paper [Towards Universal Semantics With Large Language Models](https://arxiv.org/abs/2505.11764).
20
 
21
  ## Model Details
22
 
23
  ### Model Description
24
 
25
+ DeepNSM is a fine-tuned Large Language Model (LLM) designed for generating Natural Semantic Metalanguage (NSM) explications of word-meanings. NSM is a linguistic theory based on a universal set of semantic primes that allows any word to be paraphrased into a clear, universally translatable meaning. This work addresses the traditionally slow, manual process of creating NSM explications by leveraging LLMs. The 1B and 8B DeepNSM models introduced in the paper [Towards Universal Semantics With Large Language Models](https://arxiv.org/abs/2505.11764) outperform GPT-4o in producing accurate, cross-translatable explications, marking a significant step toward universal semantic representation with LLMs.
 
 
26
 
27
+ - **Developed by:** Raymond Baartmans, Matthew Raffel, Rahul Vikram, Aiden Deringer, Lizhong Chen
28
+ - **Model type:** Text Generation, specialized in NSM explication
29
+ - **Language(s) (NLP):** English
30
+ - **License:** cc-by-nc-sa-4.0
31
+ - **Finetuned from model:** Llama-3.1-8B
32
 
33
+ ### Model Sources
34
 
35
+ - **Repository:** https://github.com/OSU-STARLAB/DeepNSM
36
+ - **Paper:** https://arxiv.org/abs/2505.11764
37
+ - **Demo:** [Colab Demo](https://colab.research.google.com/drive/1kWesMSQOgKOsXxONvZyinpdgh86gDBcy?usp=drive_link)
 
38
 
39
  ## Uses
40
 
41
  ### Direct Use
42
 
 
43
  To use the DeepNSM model to generate an NSM paraphrase of a word-meaning, you should structure your prompts in the following format:
44
  ```
45
  Word: dangerous
 
49
  Paraphrase:
50
  ```
51
 
52
+ ### Downstream Use
 
 
53
 
54
+ The generated NSM explications can offer valuable applications for many natural language processing (NLP) tasks, including semantic analysis, translation, and beyond, as they reveal clear and universally translatable meanings.
55
 
56
  ### Out-of-Scope Use
57
 
58
+ This model is specifically fine-tuned for generating NSM explications. It is not intended for general-purpose conversational AI, code generation, or other tasks for which it has not been explicitly trained or fine-tuned. Using it for out-of-scope applications may lead to suboptimal or irrelevant results.
 
 
59
 
60
  ## Bias, Risks, and Limitations
61
 
62
+ - **Language Specificity:** While NSM is designed for universality, the current model is primarily trained on English data. Its performance on generating explications for other languages, even if conceptually translatable, is not guaranteed without further multilingual fine-tuning.
63
+ - **Subjectivity in Explications:** Despite NSM's rigorous framework, human-annotated explications can sometimes have subtle variations or ambiguities. The model's output reflects the patterns learned from this data.
64
+ - **Generative Nature:** As a generative model, it may occasionally produce outputs that are grammatically correct but semantically inaccurate or nonsensical in the context of NSM theory.
65
+ - **Resource Intensive:** Running the 8B parameter model requires significant computational resources (NVIDIA GPU with >16GB VRAM), which may limit accessibility for some users.
66
 
67
  ### Recommendations
68
 
69
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. For critical applications, human review of generated explications is recommended. Further research into multilingual NSM explication and broader evaluation across diverse linguistic and cultural contexts would be beneficial.
 
 
70
 
71
  ## How to Get Started with the Model
72
 
73
+ Use the code below to get started with the model. Ensure you have the `transformers` and `torch` libraries installed. A GPU with sufficient VRAM is recommended for the 8B model.
74
 
75
+ ```python
76
+ import torch
77
+ from transformers import AutoModelForCausalLM, AutoTokenizer
78
 
79
+ model_name = "baartmar/DeepNSM-8B" # or "baartmar/DeepNSM-1B"
80
 
81
+ # Load tokenizer and model
82
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
83
+ model = AutoModelForCausalLM.from_pretrained(
84
+ model_name,
85
+ torch_dtype=torch.bfloat16, # Adjust dtype based on your GPU capabilities (e.g., torch.float16 or torch.float32)
86
+ device_map="auto" # Automatically distribute model across available GPUs
87
+ )
88
 
89
+ # Set model to evaluation mode
90
+ model.eval()
91
 
92
+ # Example prompt
93
+ prompt = """Word: dangerous
94
+ Examples:
95
+ don't go near the dangerous fire
96
+ walking outside at night is dangerous
97
+ Paraphrase:
98
+ """
99
+
100
+ # Tokenize input
101
+ input_ids = tokenizer.encode(prompt, return_tensors="pt").to(model.device)
102
+
103
+ # Generate output
104
+ with torch.no_grad():
105
+ output_ids = model.generate(
106
+ input_ids,
107
+ max_new_tokens=100, # Adjust as needed for explication length
108
+ temperature=0.7, # Adjust for creativity vs. faithfulness
109
+ do_sample=True, # Set to True for sampling, False for greedy decoding
110
+ pad_token_id=tokenizer.eos_token_id # Important for batch generation
111
+ )
112
+
113
+ # Decode and print the generated text
114
+ generated_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
115
+ print(generated_text)
116
+ ```
117
 
118
+ For a more comprehensive demonstration and local inference setup, please refer to the [Colab Demo](https://colab.research.google.com/drive/1kWesMSQOgKOsXxONvZyinpdgh86gDBcy?usp=drive_link) and the [GitHub repository](https://github.com/OSU-STARLAB/DeepNSM).
119
 
120
+ ## Training Details
121
 
122
+ ### Training Data
123
 
124
+ The model was fine-tuned on the [baartmar/nsm_dataset](https://huggingface.co/datasets/baartmar/nsm_dataset), a tailored dataset specifically designed for training and evaluating NSM explication tasks.
125
 
126
+ ### Training Procedure
127
 
128
  #### Training Hyperparameters
129
 
130
+ - **Training regime:** Mixed precision (bfloat16 for computation where supported, with 4-bit quantization as indicated by `use-4bit`, `bnb-4bit-compute-dtype bfloat16`, `bnb-4bit-quant-type nf4` in the training command).
131
+ - **LoRA parameters:** `lora_alpha=16`, `lora_dropout=0.1`, `lora_r=64` (from `adapter_config.json`).
132
+ - **Optimizer:** `paged_adamw_32bit`.
133
+ - **Learning rate:** `2e-4` with `inverse_sqrt` scheduler and `warmup_ratio=0.03`.
134
+ - **Max gradient norm:** `0.3`.
135
+ - **Max sequence length:** `256`.
136
+ - **Effective batch size:** 64 (derived from `bsz 64` and `update-freq 1` in the example training command).
137
+ - **Number of training epochs:** `1` (as specified in the `train.py` example command, though training logs show progression over multiple virtual epochs/steps up to 10000 steps).
138
 
139
+ #### Speeds, Sizes, Times
140
 
141
+ - **Checkpoints:** The DeepNSM models are available in 1B and 8B parameter variants.
142
+ - **Training Time:** The training logs (`trainer_state.json`) indicate a total of `10000` training steps completed over approximately 1.85 epochs, with evaluation steps every 1000 steps. Training for the 8B model requires a moderately strong GPU (e.g., >16GB VRAM as per requirements).
143
+ - **Total FLOPs:** `7.13 x 10^17` (from `total_flos` in `trainer_state.json`).
144
 
145
  ## Evaluation
146
 
147
+ The models were evaluated using automatic evaluation methods and compared against GPT-4o.
148
 
149
  ### Testing Data, Factors & Metrics
150
 
151
  #### Testing Data
152
 
153
+ The evaluation utilized the same [baartmar/nsm_dataset](https://huggingface.co/datasets/baartmar/nsm_dataset) used for training.
 
 
 
 
 
 
 
 
154
 
155
  #### Metrics
156
 
157
+ The paper introduces specific automatic evaluation methods tailored for the NSM explication task. Details on these metrics can be found in the research paper.
 
 
158
 
159
  ### Results
160
 
161
+ The 1B and 8B DeepNSM models consistently outperformed GPT-4o in producing accurate, cross-translatable NSM explications, marking a significant step toward universal semantic representation with LLMs. The `trainer_state.json` shows that the `eval_mean_token_accuracy` reached `0.6975` and `eval_loss` reduced to `0.9294` by the final logged step.
 
 
 
 
162
 
163
+ ## Citation
164
 
165
+ If you find our work useful or helpful for your research and applications, please feel free to cite our paper as below:
166
 
167
+ ```bibtex
168
+ @misc{baartmans2025universalsemanticslargelanguage,
169
+ title={Towards Universal Semantics With Large Language Models},
170
+ author={Raymond Baartmans and Matthew Raffel and Rahul Vikram and Aiden Deringer and Lizhong Chen},
171
+ year={2025},
172
+ eprint={2505.11764},
173
+ archivePrefix={arXiv},
174
+ primaryClass={cs.CL},
175
+ url={https://arxiv.org/abs/2505.11764},
176
+ }
177
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
  ## Model Card Contact
180
 
181
+ For any questions or further information, please refer to the [GitHub repository](https://github.com/OSU-STARLAB/DeepNSM) or contact the authors listed in the paper.
182
+
183
  ### Framework versions
184
 
185
+ - PEFT 0.15.2
186
+ - Transformers (compatible with current versions, e.g., >=4.33.2 based on typical model requirements)