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
| 9 |
+
- embeddings
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# arXiv Citation Embeddings Dataset
|
| 13 |
+
|
| 14 |
+
This dataset contains citation embeddings for arXiv papers, designed for training models that predict cited paper embeddings from citation context.
|
| 15 |
+
|
| 16 |
+
## Dataset Structure
|
| 17 |
+
|
| 18 |
+
### Core Files (Required for Training)
|
| 19 |
+
- `paper_embeddings.parquet`: Paper-level sentence embeddings (shared across splits)
|
| 20 |
+
- `train/citations.jsonl`: Training citation pairs with contexts
|
| 21 |
+
- `train/citation_embeddings_*.parquet`: Citation context embeddings (sharded)
|
| 22 |
+
- `test/citations.jsonl`: Test citation pairs with contexts
|
| 23 |
+
- `test/citation_embeddings_*.parquet`: Test citation context embeddings (sharded)
|
| 24 |
+
- `papers.jsonl`: Original paper metadata (title, abstract, citations)
|
| 25 |
+
|
| 26 |
+
### Optional Files
|
| 27 |
+
- `xml_docs/*.xml.gz`: Source XML documents from arXiv (for reproducibility/inspection)
|
| 28 |
+
|
| 29 |
+
#### Download XML Files
|
| 30 |
+
```python
|
| 31 |
+
from huggingface_hub import snapshot_download
|
| 32 |
+
|
| 33 |
+
snapshot_download(
|
| 34 |
+
repo_id="{dataset_name}",
|
| 35 |
+
repo_type="dataset",
|
| 36 |
+
allow_patterns=["xml_docs/*.xml.gz"]
|
| 37 |
+
)
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
## Usage
|
| 42 |
+
|
| 43 |
+
### Download Dataset (Excluding XML)
|
| 44 |
+
```python
|
| 45 |
+
from huggingface_hub import snapshot_download
|
| 46 |
+
|
| 47 |
+
# Download only essential training files (recommended)
|
| 48 |
+
snapshot_download(
|
| 49 |
+
repo_id="akalmbach-kinsol/generative-papers-arxiv",
|
| 50 |
+
repo_type="dataset",
|
| 51 |
+
allow_patterns=[
|
| 52 |
+
"paper_embeddings.parquet",
|
| 53 |
+
"papers.jsonl",
|
| 54 |
+
"train/*.jsonl",
|
| 55 |
+
"train/*.parquet",
|
| 56 |
+
"test/*.jsonl",
|
| 57 |
+
"test/*.parquet",
|
| 58 |
+
]
|
| 59 |
+
)
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
### Use with Custom PyTorch Dataset
|
| 63 |
+
```python
|
| 64 |
+
from arxiv_search.dataloader import CitationEmbeddingDataset
|
| 65 |
+
from pathlib import Path
|
| 66 |
+
|
| 67 |
+
# For training
|
| 68 |
+
train_ds = CitationEmbeddingDataset(
|
| 69 |
+
citations_file=Path("train/citations.jsonl"),
|
| 70 |
+
paper_embeddings_file=Path("paper_embeddings.parquet"),
|
| 71 |
+
citation_embeddings_dir=Path("train"),
|
| 72 |
+
citations_batch_size=10000,
|
| 73 |
+
shuffle=True,
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
# For testing/evaluation
|
| 77 |
+
test_ds = CitationEmbeddingDataset(
|
| 78 |
+
citations_file=Path("test/citations.jsonl"),
|
| 79 |
+
paper_embeddings_file=Path("paper_embeddings.parquet"),
|
| 80 |
+
citation_embeddings_dir=Path("test"),
|
| 81 |
+
citations_batch_size=10000,
|
| 82 |
+
shuffle=False,
|
| 83 |
+
shuffle_shards=False,
|
| 84 |
+
)
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
## Data Splits
|
| 88 |
+
|
| 89 |
+
Citations are split by **citing paper** (citer_arxiv_id) to test generalization to new sources/authors. This is the standard approach for evaluating supervised learning models.
|
| 90 |
+
|
| 91 |
+
## Embedding Model
|
| 92 |
+
|
| 93 |
+
Paper and citation embeddings are generated using [allenai-specter](https://huggingface.co/sentence-transformers/allenai-specter), a sentence transformer model trained on scientific documents.
|
| 94 |
+
|
| 95 |
+
## Citation Format
|
| 96 |
+
|
| 97 |
+
Papers use the SPECTER format: `"{title}[SEP]{abstract}"` for generating embeddings.
|
| 98 |
+
|
| 99 |
+
## Files
|
| 100 |
+
|
| 101 |
+
### paper_embeddings.parquet
|
| 102 |
+
- **Format**: Parquet
|
| 103 |
+
- **Compression**: Snappy (default)
|
| 104 |
+
- **Schema**:
|
| 105 |
+
- `arxiv_id`: string (paper identifier)
|
| 106 |
+
- `sentence_embedding`: array of float32 with shape [768]
|
| 107 |
+
|
| 108 |
+
### citations.jsonl (per split)
|
| 109 |
+
- **Format**: JSONL (newline-delimited JSON)
|
| 110 |
+
- **Schema**:
|
| 111 |
+
```json
|
| 112 |
+
{
|
| 113 |
+
"index": "integer (row index, starts from 0 for each split)",
|
| 114 |
+
"citer_arxiv_id": "string (paper making the citation)",
|
| 115 |
+
"cited_arxiv_id": "string (paper being cited)",
|
| 116 |
+
"reference_contexts": "string (text context around the citation)",
|
| 117 |
+
"reference_id": "string (base64-encoded hash of the reference context)"
|
| 118 |
+
}
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
### citation_embeddings_*.parquet (per split)
|
| 122 |
+
- **Format**: Parquet
|
| 123 |
+
- **Compression**: zstd
|
| 124 |
+
- **Naming**: Files are named with the batch start index (e.g., `citation_embeddings_0.parquet`, `citation_embeddings_5000.parquet`)
|
| 125 |
+
- **Schema**:
|
| 126 |
+
- `input_ids`: list of int32 (tokenized input)
|
| 127 |
+
- `token_type_ids`: list of int32 (segment IDs)
|
| 128 |
+
- `attention_mask`: list of int32 (attention mask for tokens)
|
| 129 |
+
- `token_embeddings`: list of arrays, each array shape [768] (embeddings per token)
|
| 130 |
+
- `sentence_embedding`: array of float32 with shape [768] (pooled sentence embedding)
|
| 131 |
+
- `reference_id`: string (base64-encoded hash matching citations.jsonl)
|
| 132 |
+
|
| 133 |
+
## Source Code
|
| 134 |
+
|
| 135 |
+
The dataset generation pipeline and model training code is available at: [arxiv_search](https://github.com/yourusername/arxiv_crawler)
|
| 136 |
+
|
| 137 |
+
## License
|
| 138 |
+
|
| 139 |
+
MIT License
|
| 140 |
+
|