neilcorp commited on
Commit
4aae51b
·
verified ·
1 Parent(s): 1e7a81f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +324 -91
README.md CHANGED
@@ -1,102 +1,240 @@
1
  ---
2
- license: mit
 
 
3
  task_categories:
4
  - text-classification
5
  - feature-extraction
6
- language:
7
- - en
8
  tags:
9
- - entity-resolution
10
  - named-entity-recognition
11
- - company-data
12
- - embeddings
 
13
  - sqlite
14
  - vector-search
 
15
  size_categories:
16
  - 1M<n<10M
 
 
 
 
 
 
17
  ---
18
 
19
  # Entity References Database
20
 
21
- A pre-built SQLite database with vector embeddings for organization/entity resolution. Used by the [corp-extractor](https://pypi.org/project/corp-extractor/) library for fast entity qualification via embedding similarity search.
22
-
23
- ## Overview
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- This database contains organization records from multiple authoritative sources, each with:
26
- - Organization name (canonical)
27
- - Source identifier (LEI, CIK, UK Company Number, Wikidata QID)
28
- - Entity type classification (business, nonprofit, government, etc.)
29
- - Vector embeddings for semantic search (768-dim, using [embeddinggemma-300m](https://huggingface.co/google/embeddinggemma-300m))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- ## Data Sources
32
 
33
- | Source | Records | Identifier | Description |
34
- |--------|---------|------------|-------------|
35
- | GLEIF | ~3.2M | LEI (Legal Entity Identifier) | Global legal entities from the LEI system |
36
- | SEC Edgar | ~100K+ | CIK (Central Index Key) | US SEC-registered filers |
37
- | Companies House | ~5M | UK Company Number | UK registered companies |
38
- | Wikidata | Variable | Wikidata QID | Notable organizations from Wikidata |
39
 
40
- ## Entity Types
 
 
 
 
41
 
42
- Organizations are classified into the following types:
 
 
 
43
 
44
- | Category | Types |
45
- |----------|-------|
46
- | Business | `business`, `fund`, `branch` |
47
- | Non-profit | `nonprofit`, `ngo`, `foundation`, `trade_union` |
48
- | Government | `government`, `international_org`, `political_party` |
49
- | Other | `educational`, `research`, `healthcare`, `media`, `sports`, `religious`, `unknown` |
50
-
51
- ## Database Variants
52
-
53
- | File | Description | Use Case |
54
- |------|-------------|----------|
55
- | `entities.db` | Full database with complete source record metadata | When you need full record details |
56
- | `entities-lite.db` | Lite version without record data | Default - faster download, smaller size |
57
- | `entities.db.gz` | Compressed full database | When bandwidth is limited |
58
- | `entities-lite.db.gz` | Compressed lite database | Smallest download size |
59
-
60
- ## Schema
61
-
62
- ### organizations table
63
- ```sql
64
- CREATE TABLE organizations (
65
- id INTEGER PRIMARY KEY AUTOINCREMENT,
66
- name TEXT NOT NULL,
67
- name_normalized TEXT NOT NULL,
68
- source TEXT NOT NULL, -- 'gleif', 'sec_edgar', 'companies_house', 'wikipedia'
69
- source_id TEXT NOT NULL,
70
- region TEXT NOT NULL DEFAULT '',
71
- entity_type TEXT NOT NULL DEFAULT 'unknown',
72
- record TEXT NOT NULL, -- JSON with full source record (empty in lite version)
73
- UNIQUE(source, source_id)
74
- );
75
- ```
76
 
77
- ### organization_embeddings table (sqlite-vec)
78
- ```sql
79
- CREATE VIRTUAL TABLE organization_embeddings USING vec0(
80
- org_id INTEGER PRIMARY KEY,
81
- embedding float[768]
82
- );
83
- ```
84
 
85
- ## Usage with corp-extractor
86
 
87
  ```bash
88
- # Install
89
  pip install corp-extractor
 
 
 
90
 
91
- # Download the database (lite version by default)
 
92
  corp-extractor db download
93
 
94
  # Download full version
95
  corp-extractor db download --full
 
 
 
 
 
96
 
97
- # Search for an organization
 
98
  corp-extractor db search "Microsoft"
99
 
 
 
 
 
 
 
 
 
 
100
  # Check database status
101
  corp-extractor db status
102
  ```
@@ -104,46 +242,141 @@ corp-extractor db status
104
  ### Python API
105
 
106
  ```python
107
- from statement_extractor.database import OrganizationDatabase, CompanyEmbedder
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
- # Load database
110
- database = OrganizationDatabase()
111
- embedder = CompanyEmbedder()
112
 
113
- # Search by embedding similarity
114
- query_embedding = embedder.embed("Microsoft Corporation")
115
- results = database.search(query_embedding, top_k=5)
116
 
117
- for record, similarity in results:
118
- print(f"{record.name} ({record.source}:{record.source_id}) - {similarity:.3f}")
119
  ```
120
 
121
- ## Building Your Own Database
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  ```bash
124
- # Import from authoritative sources
125
  corp-extractor db import-gleif --download
126
  corp-extractor db import-sec --download
127
  corp-extractor db import-companies-house --download
128
- corp-extractor db import-wikidata --limit 50000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
- # Upload to HuggingFace
131
- export HF_TOKEN="hf_..."
132
- corp-extractor db upload
 
 
133
  ```
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  ## License
136
 
137
- MIT License - the database structure and embedding generation code are MIT licensed.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
- Individual data sources have their own licenses:
140
- - GLEIF: Open license for LEI data
141
- - SEC Edgar: Public domain (US government)
142
- - Companies House: Open Government Licence
143
- - Wikidata: CC0 (public domain)
144
 
145
- ## Links
146
 
147
- - [Corp-Extractor on PyPI](https://pypi.org/project/corp-extractor/)
148
- - [Corp-Extractor GitHub](https://github.com/corp-o-rate/statement-extractor)
149
- - [Statement Extractor Model](https://huggingface.co/Corp-o-Rate-Community/statement-extractor)
 
1
  ---
2
+ language:
3
+ - en
4
+ license: apache-2.0
5
  task_categories:
6
  - text-classification
7
  - feature-extraction
 
 
8
  tags:
9
+ - entity-linking
10
  - named-entity-recognition
11
+ - knowledge-base
12
+ - organizations
13
+ - people
14
  - sqlite
15
  - vector-search
16
+ - embeddings
17
  size_categories:
18
  - 1M<n<10M
19
+ pretty_name: Entity References Database
20
+ configs:
21
+ - config_name: full
22
+ description: Full database with complete source metadata
23
+ - config_name: lite
24
+ description: Core fields + embeddings only (recommended)
25
  ---
26
 
27
  # Entity References Database
28
 
29
+ A comprehensive entity database for organizations, people, roles, and locations with 768-dimensional embeddings for semantic matching. Built from authoritative sources (GLEIF, SEC, Companies House, Wikidata) for entity linking and named entity disambiguation.
30
+
31
+ ## Dataset Description
32
+
33
+ - **Repository:** [Corp-o-Rate-Community/entity-references](https://huggingface.co/datasets/Corp-o-Rate-Community/entity-references)
34
+ - **Paper:** N/A
35
+ - **Point of Contact:** Corp-o-Rate-Community
36
+
37
+ ### Dataset Summary
38
+
39
+ This dataset provides fast lookup and qualification of named entities using vector similarity search. It stores records from authoritative global sources with embeddings generated by `google/embeddinggemma-300m` (768 dimensions).
40
+
41
+ **Key Features:**
42
+ - **8M+ organization records** from GLEIF, SEC Edgar, Companies House, and Wikidata
43
+ - **Notable people** including executives, politicians, athletes, artists, and more
44
+ - **Roles and locations** with hierarchical relationships
45
+ - **Vector embeddings** for semantic similarity search
46
+ - **Canonical linking** across sources (same entity from multiple sources linked)
47
+
48
+ ### Supported Tasks
49
+
50
+ - **Entity Linking**: Match extracted entity mentions to canonical database records
51
+ - **Named Entity Disambiguation**: Distinguish between entities with similar names
52
+ - **Knowledge Base Population**: Enrich extracted entities with identifiers and metadata
53
+
54
+ ### Languages
55
+
56
+ English (en)
57
+
58
+ ## Dataset Structure
59
+
60
+ ### Schema (v2 - Normalized)
61
 
62
+ The database uses SQLite with the [sqlite-vec](https://github.com/asg017/sqlite-vec) extension for vector similarity search.
63
+
64
+ #### Organizations Table
65
+
66
+ | Column | Type | Description |
67
+ |--------|------|-------------|
68
+ | `id` | INTEGER | Primary key |
69
+ | `qid` | INTEGER | Wikidata QID as integer (e.g., 2283 for Q2283) |
70
+ | `name` | TEXT | Organization name |
71
+ | `name_normalized` | TEXT | Lowercased, normalized name |
72
+ | `source_id` | INTEGER FK | Reference to source_types |
73
+ | `source_identifier` | TEXT | LEI, CIK, Company Number, etc. |
74
+ | `region_id` | INTEGER FK | Reference to locations |
75
+ | `entity_type_id` | INTEGER FK | Reference to organization_types |
76
+ | `from_date` | TEXT | Founding/registration date (ISO format) |
77
+ | `to_date` | TEXT | Dissolution date (ISO format) |
78
+ | `canon_id` | INTEGER | ID of canonical record |
79
+ | `canon_size` | INTEGER | Size of canonical group |
80
+ | `record` | JSON | Full source record (omitted in lite) |
81
+
82
+ #### People Table
83
+
84
+ | Column | Type | Description |
85
+ |--------|------|-------------|
86
+ | `id` | INTEGER | Primary key |
87
+ | `qid` | INTEGER | Wikidata QID as integer |
88
+ | `name` | TEXT | Display name |
89
+ | `name_normalized` | TEXT | Lowercased, normalized name |
90
+ | `source_id` | INTEGER FK | Reference to source_types |
91
+ | `source_identifier` | TEXT | QID, Owner CIK, Person number |
92
+ | `country_id` | INTEGER FK | Reference to locations |
93
+ | `person_type_id` | INTEGER FK | Reference to people_types |
94
+ | `known_for_role_id` | INTEGER FK | Reference to roles |
95
+ | `known_for_org` | TEXT | Organization name |
96
+ | `known_for_org_id` | INTEGER FK | Reference to organizations |
97
+ | `from_date` | TEXT | Role start date (ISO format) |
98
+ | `to_date` | TEXT | Role end date (ISO format) |
99
+ | `birth_date` | TEXT | Date of birth (ISO format) |
100
+ | `death_date` | TEXT | Date of death (ISO format) |
101
+ | `record` | JSON | Full source record (omitted in lite) |
102
+
103
+ #### Roles Table
104
+
105
+ | Column | Type | Description |
106
+ |--------|------|-------------|
107
+ | `id` | INTEGER | Primary key |
108
+ | `qid` | INTEGER | Wikidata QID (e.g., 484876 for CEO Q484876) |
109
+ | `name` | TEXT | Role name (e.g., "Chief Executive Officer") |
110
+ | `name_normalized` | TEXT | Normalized name |
111
+ | `source_id` | INTEGER FK | Reference to source_types |
112
+ | `canon_id` | INTEGER | ID of canonical role |
113
+
114
+ #### Locations Table
115
+
116
+ | Column | Type | Description |
117
+ |--------|------|-------------|
118
+ | `id` | INTEGER | Primary key |
119
+ | `qid` | INTEGER | Wikidata QID (e.g., 30 for USA Q30) |
120
+ | `name` | TEXT | Location name |
121
+ | `name_normalized` | TEXT | Normalized name |
122
+ | `source_id` | INTEGER FK | Reference to source_types |
123
+ | `source_identifier` | TEXT | ISO code (e.g., "US", "CA") |
124
+ | `parent_ids` | TEXT JSON | Parent location IDs in hierarchy |
125
+ | `location_type_id` | INTEGER FK | Reference to location_types |
126
+
127
+ #### Embedding Tables (sqlite-vec)
128
+
129
+ | Table | Columns |
130
+ |-------|---------|
131
+ | `organization_embeddings` | org_id INTEGER, embedding FLOAT[768] |
132
+ | `organization_embeddings_scalar` | org_id INTEGER, embedding INT8[768] |
133
+ | `person_embeddings` | person_id INTEGER, embedding FLOAT[768] |
134
+ | `person_embeddings_scalar` | person_id INTEGER, embedding INT8[768] |
135
+
136
+ **Scalar (int8) embeddings** provide 75% storage reduction with ~92% recall at top-100.
137
+
138
+ #### Enum Lookup Tables
139
+
140
+ | Table | Values |
141
+ |-------|--------|
142
+ | `source_types` | gleif, sec_edgar, companies_house, wikidata |
143
+ | `people_types` | executive, politician, government, military, legal, professional, academic, artist, media, athlete, entrepreneur, journalist, activist, scientist, unknown |
144
+ | `organization_types` | business, fund, branch, nonprofit, ngo, foundation, government, international_org, political_party, trade_union, educational, research, healthcare, media, sports, religious, unknown |
145
+ | `simplified_location_types` | continent, country, subdivision, city, district, other |
146
+
147
+ ### Data Splits
148
+
149
+ | Config | Size | Contents |
150
+ |--------|------|----------|
151
+ | `entities-lite.db` | ~50GB | Core fields + embeddings only |
152
+ | `entities.db` | ~74GB | Full records with source metadata |
153
+
154
+ The lite version is recommended for most use cases.
155
+
156
+ ## Dataset Creation
157
+
158
+ ### Source Data
159
+
160
+ #### Organizations
161
+
162
+ | Source | Records | Identifier | Coverage |
163
+ |--------|---------|------------|----------|
164
+ | [GLEIF](https://www.gleif.org/) | ~3.2M | LEI (Legal Entity Identifier) | Global companies with LEI |
165
+ | [SEC Edgar](https://www.sec.gov/) | ~100K+ | CIK (Central Index Key) | All SEC filers |
166
+ | [Companies House](https://www.gov.uk/government/organisations/companies-house) | ~5M | Company Number | UK registered companies |
167
+ | [Wikidata](https://www.wikidata.org/) | Variable | QID | Notable companies worldwide |
168
+
169
+ #### People
170
+
171
+ | Source | Records | Identifier | Coverage |
172
+ |--------|---------|------------|----------|
173
+ | [Wikidata](https://www.wikidata.org/) | Variable | QID | Notable people with English Wikipedia |
174
+ | [SEC Form 4](https://www.sec.gov/) | ~280K/year | Owner CIK | US public company insiders |
175
+ | [Companies House](https://www.gov.uk/government/organisations/companies-house) | ~15M+ | Person number | UK company officers |
176
+
177
+ ### Embedding Model
178
+
179
+ | Property | Value |
180
+ |----------|-------|
181
+ | Model | `google/embeddinggemma-300m` |
182
+ | Dimensions | 768 |
183
+ | Framework | sentence-transformers |
184
+ | Size | ~300M parameters |
185
 
186
+ ### Canonicalization
187
 
188
+ Records are linked across sources based on:
 
 
 
 
 
189
 
190
+ **Organizations:**
191
+ 1. Same LEI (globally unique)
192
+ 2. Same ticker symbol
193
+ 3. Same CIK
194
+ 4. Same normalized name + region
195
 
196
+ **People:**
197
+ 1. Same Wikidata QID
198
+ 2. Same normalized name + same organization
199
+ 3. Same normalized name + overlapping date ranges
200
 
201
+ **Source priority:** gleif > sec_edgar > companies_house > wikidata
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
+ ## Usage
 
 
 
 
 
 
204
 
205
+ ### Installation
206
 
207
  ```bash
 
208
  pip install corp-extractor
209
+ ```
210
+
211
+ ### Download
212
 
213
+ ```bash
214
+ # Download lite version (recommended)
215
  corp-extractor db download
216
 
217
  # Download full version
218
  corp-extractor db download --full
219
+ ```
220
+
221
+ **Storage location:** `~/.cache/corp-extractor/entities-v2.db`
222
+
223
+ ### Search
224
 
225
+ ```bash
226
+ # Search organizations
227
  corp-extractor db search "Microsoft"
228
 
229
+ # Search people
230
+ corp-extractor db search-people "Tim Cook"
231
+
232
+ # Search roles
233
+ corp-extractor db search-roles "CEO"
234
+
235
+ # Search locations
236
+ corp-extractor db search-locations "California"
237
+
238
  # Check database status
239
  corp-extractor db status
240
  ```
 
242
  ### Python API
243
 
244
  ```python
245
+ from statement_extractor.database import OrganizationDatabase, PersonDatabase
246
+
247
+ # Search organizations
248
+ org_db = OrganizationDatabase()
249
+ matches = org_db.search_by_name("Microsoft Corporation", top_k=5)
250
+ for match in matches:
251
+ print(f"{match.company.name} ({match.company.source}:{match.company.source_id})")
252
+ print(f" Similarity: {match.similarity_score:.3f}")
253
+
254
+ # Search people
255
+ person_db = PersonDatabase()
256
+ matches = person_db.search_by_name("Tim Cook", top_k=5)
257
+ for match in matches:
258
+ print(f"{match.person.name} - {match.person.known_for_role} at {match.person.known_for_org}")
259
+ ```
260
+
261
+ ### Use in Pipeline
262
 
263
+ ```python
264
+ from statement_extractor.pipeline import ExtractionPipeline
 
265
 
266
+ pipeline = ExtractionPipeline()
267
+ ctx = pipeline.process("Microsoft CEO Satya Nadella announced new AI features.")
 
268
 
269
+ for stmt in ctx.labeled_statements:
270
+ print(f"{stmt.subject_fqn} --[{stmt.statement.predicate}]--> {stmt.object_fqn}")
271
  ```
272
 
273
+ ## Technical Details
274
+
275
+ ### Vector Search Performance
276
+
277
+ | Database Size | Search Time | Memory |
278
+ |---------------|-------------|--------|
279
+ | 100K records | ~50ms | ~500MB |
280
+ | 1M records | ~200ms | ~3GB |
281
+ | 8M records | ~500ms | ~20GB |
282
+
283
+ ### Similarity Thresholds
284
+
285
+ | Score | Interpretation |
286
+ |-------|----------------|
287
+ | > 0.85 | Strong match (likely same entity) |
288
+ | 0.70 - 0.85 | Good match (probable same entity) |
289
+ | 0.55 - 0.70 | Moderate match (may need verification) |
290
+ | < 0.55 | Weak match (likely different entity) |
291
+
292
+ ### Canonical ID Format
293
+
294
+ | Source | Prefix | Example |
295
+ |--------|--------|---------|
296
+ | GLEIF | `LEI` | `LEI:INR2EJN1ERAN0W5ZP974` |
297
+ | SEC Edgar | `SEC-CIK` | `SEC-CIK:0000789019` |
298
+ | Companies House | `UK-CH` | `UK-CH:00445790` |
299
+ | Wikidata | `WIKIDATA` | `WIKIDATA:Q2283` |
300
+
301
+ ## Building from Source
302
 
303
  ```bash
304
+ # Import data sources
305
  corp-extractor db import-gleif --download
306
  corp-extractor db import-sec --download
307
  corp-extractor db import-companies-house --download
308
+ corp-extractor db import-wikidata --limit 100000
309
+ corp-extractor db import-people --all --limit 50000
310
+
311
+ # Link equivalent records
312
+ corp-extractor db canonicalize
313
+
314
+ # Generate scalar embeddings (75% smaller)
315
+ corp-extractor db backfill-scalar
316
+
317
+ # Create lite version for deployment
318
+ corp-extractor db create-lite ~/.cache/corp-extractor/entities.db
319
+ ```
320
+
321
+ ### Wikidata Dump Import (Recommended for Large Imports)
322
+
323
+ ```bash
324
+ # Download and import from Wikidata dump (~100GB)
325
+ corp-extractor db import-wikidata-dump --download --limit 50000
326
+
327
+ # Import only people
328
+ corp-extractor db import-wikidata-dump --download --people --no-orgs
329
 
330
+ # Import only locations
331
+ corp-extractor db import-wikidata-dump --dump dump.json.bz2 --locations --no-people --no-orgs
332
+
333
+ # Resume interrupted import
334
+ corp-extractor db import-wikidata-dump --dump dump.bz2 --resume
335
  ```
336
 
337
+ ## Considerations for Using the Data
338
+
339
+ ### Social Impact
340
+
341
+ This dataset enables entity linking for NLP applications. Users should be aware that:
342
+ - Organization and people records may be incomplete or outdated
343
+ - Historic people (deceased) are included with `death_date` field
344
+ - Not all notable entities are covered
345
+
346
+ ### Biases
347
+
348
+ - Coverage is weighted toward English-speaking countries (US, UK) due to source availability
349
+ - Wikidata coverage depends on Wikipedia notability criteria
350
+ - SEC and Companies House data is limited to their respective jurisdictions
351
+
352
+ ### Limitations
353
+
354
+ - The database does not automatically deduplicate across sources
355
+ - Embedding similarity is not perfect for entity disambiguation
356
+ - Updates require re-importing from source data
357
+
358
  ## License
359
 
360
+ Apache 2.0
361
+
362
+ ## Citation
363
+
364
+ If you use this dataset, please cite:
365
+
366
+ ```bibtex
367
+ @dataset{entity_references_2024,
368
+ title = {Entity References Database},
369
+ author = {Corp-o-Rate-Community},
370
+ year = {2024},
371
+ publisher = {Hugging Face},
372
+ url = {https://huggingface.co/datasets/Corp-o-Rate-Community/entity-references}
373
+ }
374
+ ```
375
+
376
+ ## Dataset Card Authors
377
 
378
+ Corp-o-Rate-Community
 
 
 
 
379
 
380
+ ## Dataset Card Contact
381
 
382
+ Open an issue on the [GitHub repository](https://github.com/corp-o-rate/statement-extractor) for questions or feedback.