File size: 6,916 Bytes
30c6fad
 
9f3f01d
 
 
 
 
 
 
 
 
4d41d82
 
 
 
 
 
 
 
 
 
 
 
3653d9b
4d41d82
 
3653d9b
4d41d82
 
3653d9b
4d41d82
 
 
 
3653d9b
4d41d82
3653d9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4d9f785
3653d9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
---
license: cc-by-nc-4.0
language:
- fr
metrics:
- accuracy
- recall
- precision
- f1
library_name: spacy
pipeline_tag: token-classification
tags:
- spacy
- token-classification
model-index:
- name: fr_spacy_custom_spancat_edda
  results:
  - task:
      name: spancat
      type: span-classification
    metrics:
    - name: Span Precision
      type: precision
      value: 0.948
    - name: Span Recall
      type: recall
      value: 0.849
    - name: Span F1 Score
      type: f_score
      value: 0.896
---



# spaCy custom spancat for Diderot & d’Alembert’s Encyclopédie entries


<!-- Provide a quick summary of what the model is/does. -->

This model identify and classify spans of text for named entities (Spatial, Person and MISC), nested named entities (Spatial, Person and MISC), spatial relations and others from French encyclopaedic entries.

The spans detected by this model are:
- **NC-Spatial**: 
- **NP-Spatial**: 
- **ENE-Spatial**:  
- **Relation**: spatial relations, e.g. 
- **Latlong**: geographic coordinates, e.g. 
- **NC-Person**: 
- **NP-Person**: 
- **ENE-Person**: 
- **NP-Misc**: 
- **ENE-Misc**: 
- **Head**: 
- **Domain-Mark**: , e.g. Géographie, Histoire

  
## Model Details

### Model Description

<!-- Provide a longer summary of what this model is. -->

- **Developed by:** [Ludovic Moncla](https://ludovicmoncla.github.io), Katherine McDonough and Denis Vigier
- **Model type:** spaCy Span Categorization
- **spaCy**: `>=3.7.2,<3.8.0`
- **Components**: `tok2vec`, `spancat`
- **Language(s) (NLP):** French
- **License:** cc-by-nc-4.0



### Model Sources

<!-- Provide the basic links for the model. -->

- **Repository:** https://github.com/GEODE-project/ner-spancat-edda


## Uses

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->

This model can be used to extract entities from any text that are Paeleoecology related or tangential. Potential uses include identifying unique SITE names in research papers in other domains. 


## Bias, Risks, and Limitations

<!-- This section is meant to convey both technical and sociotechnical limitations. -->

This model was trained entirely on French encyclopaedic entries and will likely not perform well on text in other languages. 
Also, the paragraphs used to train the model were chosen based on being already present in the Neotoma database and therefore may have selection bias as they represent what is already known to be relevant to Neotoma and may not correctly manage new, previously missed articles.


## How to Get Started with the Model

Use the code below to get started with the model.

```bash
pip install https://huggingface.co/GEODE/fr_spacy_custom_spancat_edda/resolve/main/fr_spacy_custom_spancat_edda-any-py3-none-any.whl
```

```python
# Using spacy.load().
import spacy
nlp = spacy.load("fr_spacy_custom_spancat_edda")

# Importing as module.
import fr_spacy_custom_spancat_edda
nlp = fr_spacy_custom_spancat_edda.load()
doc = nlp("* ALBI, (Géog.) ville de France, capitale de  l'Albigeois, dans le haut Languedoc : elle est sur le Tarn. Long. 19. 49. lat. 43. 55. 44.")

spans = []

for span in doc.spans['sc']:
  print(span)
  spans.append({
      "start": span.start_char,
      "end": span.end_char,
      "labels": [span.label_],
      "text": span.text
  })

print(spans)

# Output
[{'start': 2, 'end': 6, 'labels': ['Head'], 'text': 'ALBI'},
 {'start': 16, 'end': 21, 'labels': ['NC-Spatial'], 'text': 'ville'},
 {'start': 25, 'end': 31, 'labels': ['NP-Spatial'], 'text': 'France'},
 {'start': 33, 'end': 41, 'labels': ['NC-Spatial'], 'text': 'capitale'},
 {'start': 59, 'end': 63, 'labels': ['Relation'], 'text': 'dans'},
 {'start': 93, 'end': 96, 'labels': ['Relation'], 'text': 'sur'},
 {'start': 9, 'end': 14, 'labels': ['Domain-mark'], 'text': 'Géog.'},
 {'start': 46, 'end': 57, 'labels': ['NP-Spatial'], 'text': "l'Albigeois"},
 {'start': 97, 'end': 104, 'labels': ['NP-Spatial'], 'text': 'le Tarn'},
 {'start': 16,
  'end': 31,
  'labels': ['ENE-Spatial'],
  'text': 'ville de France'},
 {'start': 64,
  'end': 81,
  'labels': ['NP-Spatial'],
  'text': 'le haut Languedoc'},
 {'start': 33,
  'end': 57,
  'labels': ['ENE-Spatial'],
  'text': "capitale de  l'Albigeois"},
 {'start': 33,
  'end': 81,
  'labels': ['ENE-Spatial'],
  'text': "capitale de  l'Albigeois, dans le haut Languedoc"},
 {'start': 16,
  'end': 81,
  'labels': ['ENE-Spatial'],
  'text': "ville de France, capitale de  l'Albigeois, dans le haut Languedoc"}]
```


## Training Details

### Training Data

<!-- This should link to a Data 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. -->

The model was trained using a set of 2200 paragraphs randomly selected out of xx Encyclopédie's entries. 
All paragraphs were written in French and are distributed as follows among the Encyclopédie knowledge domains:

| Knowledge domain | Paragraphs | 
|---|:---:|
| Géographie | 1096 | 
| Histoire | 259 | 
| Droit Jurisprudence | 113 | 
| Physique | 92 | 
| Métiers | 92 | 
| Médecine | 88 | 
| Philosophie | 69 | 
| Histoire naturelle | 65 | 
| Belles-lettres | 65 | 
| Militaire | 62 | 
| Commerce | 48 | 
| Beaux-arts | 44 | 
| Agriculture | 36 | 
| Chasse | 31 | 
| Religion | 23 | 
| Musique | 17 | 


The spans/entities were labeled by the project team along with using pre-labelling with early models to speed up the labelling process. 
A train/val/test split was used.
Validation and test sets are composed of 200 paragraphs each: 100 classified as 'Géographie' and 100 from another knowledge domain.
The datasets have the following breakdown of tokens and spans/entities. 

|   | Train | Validation | Test|
|---|:---:|:---:|:---:|
|Paragraphs| 1800 | 200 | 200|
| Tokens |  |  |  |
| NC-Spatial |  |  |  |
| NP-Spatial |  |  |  |
| ENE-Spatial |  |  |  |
| Relation |  |  |  |
| Latlong |  |  |  |
| NC-Person |  |  |  |
| NP-Person |  |  |  |
| ENE-Person |  |  |  |
| NP-Misc |  |  |  |
| ENE-Misc |  |  |  |
| Head |  |  |  |
| Domain-Mark |  |  |  |


### Training Procedure 

<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->

For full training details and results please see the GitHub repository: [github.com/GEODE-project/ner-spancat-edda](https://github.com/GEODE-project/ner-spancat-edda)

## Acknowledgement

Data courtesy the [ARTFL Encyclopédie Project](https://artfl-project.uchicago.edu), University of Chicago.

The authors are grateful to the [ASLAN project](https://aslan.universite-lyon.fr) (ANR-10-LABX-0081) of the Université de Lyon, for its financial support within the French program "Investments for the Future" operated by the National Research Agency (ANR).