Spaces:
Running
Running
from fasthtml.common import * | |
from fasthtml.components import * | |
import json | |
from fh_plotly import plotly2fasthtml | |
import pandas as pd | |
import plotly.express as px | |
#Perplexity Across Different Buckets (global) | |
DATA = { | |
"2014": "1-1": 17.410227605477868, | |
"2014": "2-5": 16.11176217183986, | |
"2014": "6-10": 15.632757662414805, | |
"2014": "11-100": 15.446116676532212, | |
"2014": "101-1000": 16.716943171826703, | |
"2014": "1001-30000000": 18.156821563322765, | |
} | |
Perplexity_Across_Different_Buckets_global = pd.DataFrame( | |
DATA, columns=["Year", "Bucket", "Perplexity"] | |
) | |
fig = px.line( | |
Perplexity_Across_Different_Buckets_global, | |
x="Bucket", | |
y="Perplexity", | |
labels={"Bucket": "Bucket", "Perplexity": "Perplexity"}, | |
) | |
Perplexity_Across_Different_Buckets_global_graph = fig | |
intro_div = Div( | |
H2("Perplexity Evaluation on Duplicate Data"), | |
H3("Model based Quality Estimation"), | |
P("We took one of the model-based data quality evaluation strategies adopted by [DataComp-LM](https://arxiv.org/abs/2406.11794), which used perplexity filtering as a candidate for quality filtering. DataComp-LM followed [CCNet’s](https://arxiv.org/abs/1911.00359) practice to use a 5-gram Kneser-Ney model as implemented in the [KenLM](https://github.com/kpu/kenlm) library for efficient perplexity calculation. Following this practice, we estimated data quality by taking a KenLM model (from [edugp/kenlm](https://huggingface.co/edugp/kenlm)) trained on English Wikipedia data to compute perplexity on data with different duplication patterns. Lower perplexity is regarded as a signal of higher quality."), | |
H3("Sampling Strategy"), | |
P("We started from a processed Common Crawl (CC) ablation dataset divided by the number of duplicates of each document. For each CC dump, we have different buckets each holding chunks of document with different duplicate count ranges (1-1, 2-5, 6-10, 11-100, 101-1000, 1001-30000000). We sampled the first 10k documents from each chunk with their meta data."), | |
) | |
perp1_div = Div( | |
Section( | |
H3("Perplexity vs Buckets"), | |
P("For each bucket, we aggregated all the chunks that belong to a single year and calculated the average perplexity for each (bucket, year) data point."), | |
Img(src="images/prep-diff-buckets-global.png", height = "300", width = "600" ), | |
), | |
Section( | |
H3("Perplexity vs Years"), | |
P("Taking the same data, we can convert it into a graph indicating the yearly trend. For most buckets, the average perplexity of dumps from more recent years seem to be lower than that of former years."), | |
Img(src="images/prep-across-diff-year-global-dup-buckets.png", height = "300", width = "600" ), | |
), | |
Section( | |
H3("Perplexity vs Document Duplication"), | |
P("We can also break each bucket into distinct document counts. The graph becomes a bit noisy at the end because of insufficient samples with larger duplication counts."), | |
Img(src="images/prep-across-diff-docs-dup-count-global.png", height = "300", width = "600" ), | |
), | |
Section( | |
H3("Perplexity vs Dump Duplication"), | |
P("We are also interested in how the number of dumps a document is in affect data quality. From the graph below we can see that documents that are duplicated across around 40 - 60 dumps usually have lower perplexity."), | |
Img(src="images/prep-across-diff-dump-dup-counts-global.png", height = "300", width = "600" ), | |
), | |
Section( | |
H3("Perplexity vs Local Buckets"), | |
P("Previously we have seen that documents in recent dumps tend to have lower perplexity. This might be related to the way how global deduplication was implemented. During global deduplication, we only keep copy in the latest dump. Hence documents that are duplicated across multiple dumps only appear in the latest one. To avoid bias brought by this strategy, we tried to recover the states before the global deduplication by reading the metadata attached with each document."), | |
Img(src="images/prep-across-diff-buckets-local.png", height = "300", width = "600" ), | |
), | |
Section( | |
H3("Perplexity vs Local Dump Duplication"), | |
P("Following the same practice, we can plot the local version of the graph of average perplexity with respect to dump duplication."), | |
Img(src="images/prep-diff-dump-dump-counts-local.png", height = "300", width = "600" ), | |
), | |
) | |
llama_div = Div( | |
Section( | |
H2("Llama 3.1 8B"), | |
P("For comparison purpose, we run the same perplexity evaluation with llama 3.1 8B model.") | |
), | |
Section( | |
H3("Perplexity vs Buckets"), | |
Img(src="images/perp-across-diff-buckets-global.png", height = "300", width = "600" ), | |
), | |
Section( | |
H3("Perplexity vs Years"), | |
Img(src="images/prep-across-diff-years-global.png", height = "300", width = "600" ), | |
), | |
Section( | |
H3("Perplexity vs Dump Duplication"), | |
Img(src="images/prep-vs-dump-dup-global.png", height = "300", width = "600" ), | |
), | |
Section( | |
H3("Perplexity vs Local Buckets"), | |
Img(src="images/prep-diff-buckets-local.png", height = "300", width = "600" ), | |
), | |
Section( | |
H3("Perplexity vs Local Dump Duplication"), | |
Img(src="images/prep-vs-dump-dup-global.png", height = "300", width = "600" ), | |
), | |
) | |
def results(): | |
return Div( | |
Section( | |
intro_div, | |
perp1_div, | |
llama_div, | |
P("test plotly"), | |
plotly2fasthtml(Perplexity_Across_Different_Buckets_global_graph), | |
id="inner-text" | |
) | |
) | |