File size: 3,575 Bytes
9dce9b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
pretty_name: TruthfulQA in Lance
license: apache-2.0
language:
- en
task_categories:
- question-answering
- text-generation
- multiple-choice
tags:
- lance
- benchmark
- information-retrieval
- truthfulness
size_categories:
- 1K<n<10K
configs:
- config_name: generation
  data_files:
  - split: validation
    path: viewer/generation/validation-00000-of-00001.parquet
- config_name: multiple_choice
  data_files:
  - split: validation
    path: viewer/multiple_choice/validation-00000-of-00001.parquet
---

# TruthfulQA in Lance

Find TruthfulQA benchmark questions by topic, then read their benchmark category and reference answers. [Pinned original dataset](https://huggingface.co/datasets/truthfulqa/truthful_qa/tree/741b8276f2d1982aa3d5b832d3ee81ed3b896490)

## Data and splits

| Source configuration | Split | Rows | Lance table |
|---|---|---:|---|
| `generation` | `validation` | 817 | [`data/generation/validation.lance`](data/generation/validation.lance) |
| `multiple_choice` | `validation` | 817 | [`data/multiple_choice/validation.lance`](data/multiple_choice/validation.lance) |

Both configurations keep every original field, row, and row order. The generation configuration includes the question, category, reference answers, and intentionally incorrect benchmark answers. The multiple-choice configuration preserves both sets of choices and labels. The `source_row` column gives the original zero-based row position within each configuration. [Conversion manifest and source checksums](meta/conversion.json)

Hugging Face Data Studio reads the byte-identical original Parquet files in `viewer/`. [Open the preview](https://huggingface.co/datasets/lance-format/truthful-qa-lance/viewer/generation/validation)

## Search in Python

The release generates a 1024-dimensional, L2-normalized float32 vector from each original English `question`. It uses `sentence-transformers/static-retrieval-mrl-en-v1` at revision `f60985c706f192d45d218078e49e5a8b6f15283a`. Search ranks by cosine distance and prints cosine similarity as `1 - distance`. [Pinned encoder](https://huggingface.co/sentence-transformers/static-retrieval-mrl-en-v1/tree/f60985c706f192d45d218078e49e5a8b6f15283a)

```bash
pip install pylance==14.0.3 sentence-transformers==6.3.0
```

```python
import lance
from sentence_transformers import SentenceTransformer

encoder = SentenceTransformer(
    "sentence-transformers/static-retrieval-mrl-en-v1",
    revision="f60985c706f192d45d218078e49e5a8b6f15283a",
    device="cpu",
)
query = "Common misconceptions about the planets and the motion of Earth."
vector = encoder.encode_query(query, normalize_embeddings=True)
dataset = lance.dataset("hf://datasets/lance-format/truthful-qa-lance/data/generation/validation.lance")
hits = dataset.to_table(
    columns=["source_row", "question", "category", "best_answer", "_distance"],
    nearest={"column": "embedding", "q": vector, "k": 5, "metric": "cosine"},
).to_pylist()
for hit in hits:
    print(f"{1.0 - hit['_distance']:.4f}  row={hit['source_row']}  {hit['category']}")
    print(hit["question"])
    print(f"Benchmark answer: {hit['best_answer']}")
```

## Attribution and license

Credit Stephanie Lin, Jacob Hilton, and Owain Evans for *TruthfulQA: Measuring How Models Mimic Human Falsehoods*. The authors release the source under Apache 2.0. This conversion adds a split-local identifier and the retrieval embedding. [License](LICENSE) · [Original dataset card](source/README.md) · [Authors' repository](https://github.com/sylinrl/TruthfulQA) · [Paper](https://arxiv.org/abs/2109.07958)