BPIMB es una colección de incrustaciones de subvenciones previamente capacitadas en 275 idiomas, basada en la codificación de pares de bytes (BPE) y entrenado en Wikipedia. Su uso previsto es como entrada para los modelos neuronales en el procesamiento del lenguaje natural.
Sitio web ・ Uso ・ Descargar ・ Multibpembember ・ Paper (PDF) ・ citando BPIMB
Instale BPIMB con PIP:
pip install bpembLos modelos de inserción y forma de oración se descargarán automáticamente la primera vez que los use.
> >> from bpemb import BPEmb
# load English BPEmb model with default vocabulary size (10k) and 50-dimensional embeddings
> >> bpemb_en = BPEmb ( lang = "en" , dim = 50 )
downloading https : // nlp . h - its . org / bpemb / en / en . wiki . bpe . vs10000 . model
downloading https : // nlp . h - its . org / bpemb / en / en . wiki . bpe . vs10000 . d50 . w2v . bin . tar . gzPuedes hacer dos cosas principales con BPIMB. El primero es la segmentación de la subvención:
# apply English BPE subword segmentation model
> >> bpemb_en . encode ( "Stratford" )
[ '▁strat' , 'ford' ]
# load Chinese BPEmb model with vocabulary size 100k and default (100-dim) embeddings
> >> bpemb_zh = BPEmb ( lang = "zh" , vs = 100000 )
# apply Chinese BPE subword segmentation model
> >> bpemb_zh . encode ( "这是一个中文句子" ) # "This is a Chinese sentence."
[ '▁这是一个' , '中文' , '句子' ] # ["This is a", "Chinese", "sentence"]Si / cómo se divide una palabra depende del tamaño del vocabulario. En general, un tamaño de vocabulario más pequeño producirá una segmentación en muchas subvenciones, mientras que un gran tamaño de vocabulario dará como resultado que las palabras frecuentes no se dividan:
| tamaño de vocabulario | segmentación |
|---|---|
| 1000 | ['Ort', 'at', 'f', 'ord'] |
| 3000 | ['Ort', 'at', 'ford'] |
| 5000 | ['Ort', 'at', 'ford'] |
| 10000 | ['Strat', 'Ford'] |
| 25000 | ['S Stratford'] |
| 50000 | ['S Stratford'] |
| 100000 | ['S Stratford'] |
| 200000 | ['S Stratford'] |
El segundo propósito de BPEMB es proporcionar incrustaciones de subvención previa a la detención:
# Embeddings are wrapped in a gensim KeyedVectors object
> >> type ( bpemb_zh . emb )
gensim . models . keyedvectors . Word2VecKeyedVectors
# You can use BPEmb objects like gensim KeyedVectors
> >> bpemb_en . most_similar ( "ford" )
[( 'bury' , 0.8745079040527344 ),
( 'ton' , 0.8725000619888306 ),
( 'well' , 0.871537446975708 ),
( 'ston' , 0.8701574206352234 ),
( 'worth' , 0.8672043085098267 ),
( 'field' , 0.859795331954956 ),
( 'ley' , 0.8591548204421997 ),
( 'ington' , 0.8126075267791748 ),
( 'bridge' , 0.8099068999290466 ),
( 'brook' , 0.7979353070259094 )]
> >> type ( bpemb_en . vectors )
numpy . ndarray
> >> bpemb_en . vectors . shape
( 10000 , 50 )
> >> bpemb_zh . vectors . shape
( 100000 , 100 )Para utilizar los incrustaciones de subvenciones en su red neuronal, codifique su entrada en ID de subvención:
> >> ids = bpemb_zh . encode_ids ( "这是一个中文句子" )
[ 25950 , 695 , 20199 ]
> >> bpemb_zh . vectors [ ids ]. shape
( 3 , 100 ) O use el método embed :
# apply Chinese subword segmentation and perform embedding lookup
> >> bpemb_zh . embed ( "这是一个中文句子" ). shape
( 3 , 100 )ab (Abkhazian) ・ ace (Achinese) ・ ady (Adyghe) ・ af (Afrikaans) ・ ak (Akan) ・ als (Alemannic) ・ am (Amharic) ・ an (Aragonese) ・ ang (Old English) ・ ar (Arabic) ・ arc (Official Aramaic) ・ arz (Egyptian Arabic) ・ as (Assamese) ・AST (ASTURIANO) ・ ATJ (ATIKAMEKW) ・ AV (AVARIC) ・ AY (AYMARA) ・ AZ (AZERBAIYANI) ・ AZB (South Azerbaiyani)
Ba (Bashkir) ・ Bar (bávaro) ・ bcl (Central Bikol) ・ be (bielorruso) ・ bg (búlgaro) ・ bi (bislama) ・ bjn (banjar) ・ bm (bambara) ・ bn (benguali) ・ bo (tibetano) ・ bpy (bishnupriya) (Bosnian) ・ Error (Buginés) ・ BXR (Rusia Buriat)
Ca (catalán) ・ CDO (min dong chino) ・ ce (chechen) ・ ceb (cebuano) ・ ch (chamorro) ・ chr (cherokee) ・ chy (cheyenne) ・ ckb (kurdish) ・ co (Corsican) (Kashubian) ・ CU (Church Slavic) ・ CV (Chuvash) ・ Cy (galés)
da (danés) ・ de (alemán) ・ din (dinka) ・ diq (dimli) ・ dsb (sorbian inferior) ・ dty (dotyali) ・ dv (dhivehi) ・ dz (dzongkha)
ee (ewe) ・ el (griego moderno) ・ en (inglés) ・ eo (esperanto) ・ es (español) ・ et (estonio) ・ eu (vasco) ・ ext (extremado)
fa (persa) ・ ff (forah) ・ Fi (finlandés) ・ fj (fiyiano) ・ fo (faroese) ・ fr (francés) ・ frp (arpitan) ・ frr (norte de frisio) ・ pieles (friulianas) ・ fy (frisia occidental))
Ga (irlandés) ・ gag (gagauz) ・ gan (gan chino) ・ gd (gaélico escocés) ・ gl (galicáne) ・ glk (gilaki) ・ gn (guarani) ・ gom (goan konkani) ・ got (gótica) ・ Gu (Gujarati) ・ gv (manx)
ha (hausa) ・ hak (hakka chino) ・ haw (hawaiano) ・ he (hebreo) ・ hi (hindi) ・ hif (fiji hindi) ・ hr (croata) ・ hsb (sorbian) ・ ht (haitiano) ・ hu (húngariano) ・ (armeniano)
ia (interlingua) ・ id (indonesio) ・ ie (interlingue) ・ ig (igbo) ・ ik (inupiaq) ・ ilo (iloko) ・ io (ido) ・ es (islandés) ・ it (italiano) ・ iu (inucitut)
JA (japonés) ・ Jam (inglés jamaicano inglés) ・ jbo (lojban) ・ jv (javanese)
Ka (georgiano) ・ kaa (kara-kalpak) ・ kab (kabyle) ・ kbd (kabardian) ・ kbp (kabiyè) ・ kg (kongo) ・ ki (kikuyu) ・ kk (kazakh) Ko (coreano) ・ koi (komi-permyak) ・ krc (karachay-balkar) ・ ks (kashmiri) ・ ksh (kölsch) ・ ku (kurdish) ・ kv (komi) ・ kw (cornish) ・ ky (kirghiz)
la ((latín) ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ lb (Luxemburgo) (Lituano) ・ Ltg (latgaliano) ・ lv (latvia)
mai (maithili) ・ mdf (moksha) ・ mg (malgache) ・ mh (marshallese) ・ mhr (oriental mari) ・ mi (maori) ・ min (minangkabau) ・ mk (macedonio) ・ ml (malayalam) ・ mnmn (mongolian) ・ mr (marati) ms ・ ・ ・) (Malayo) ・ mt (maltés) ・ mwl (Mirandés) ・ my (birmano) ・ myv (erzya) ・ mzn (mazanderani)
na (nauru) ・ nap (napolitan) ・ nds (bajo alemán) ・ ne (nepali) ・ nuevo (newari) ・ ng (ndonga) ・ nl (holandés) ・ nn (norwegian nynorsk) ・ no (norwegian) ・ novié NY (Nyanja)
OC (Occitan) ・ Olo (Livvi) ・ OM (Oromo) ・ o (Oriya) ・ OS (Osetian)
PA (Panjabi) ・ Pag (Pangasinan) ・ Pam (Pampanga) ・ PAP (PapiMentO) ・ PCD (Picard) ・ PDC (Pennsylvania German) ・ Pfl (Pfaelzisch) ・ Pi (Pali) ・ PIH (PITN-NORFOLE) (Western Panjabi) ・ Pnt (Pontic) ・ PS (Pushto) ・ Pt (portugués)
Qu (quechua)
RM (Romansh) ・ RMY (Vlax Romani) ・ Rn (Rundi) ・ Ro (rumano) ・ Ru (ruso) ・ rue (Rusyn) ・ RW (Kinyarwanda)
Sa (sánscrito) ・ sah (yakut) ・ sc (sardiniano) ・ scn (siciliano) ・ sco (scots) ・ sd (sindhi) ・ se (norte de sami) ・ sg (sango) ・ sh (serbo-croatian)・ Sn (shona) ・ So (somali) ・ sq (albanés) ・ sr (serbio) ・ srn (sranan tongo) ・ ss (swati) ・ st (sur sotho) ・ stq (satriesisch) ・ su (SUNDANESE) ・ SV (SweDish) ・ SW (Swahili) ・ Szián)
ta (tamil) ・ tcy (tulu) ・ te (telugu) ・ tet (tetum) ・ tg (tajik) ・ th (thai) ・ ti (tigrinya) ・ tk (turkmen) ・ tl (tagalog) ・ tn (tswana) ・ to (time) ・ tpi (tok pisin) ・ ・ tn) (Tsonga) ・ tt (tatar) ・ tum (tumbuka) ・ tw (twi) ・ ty (tahitiano) ・ tyv (tuviniano)
udm (udmurt) ・ ug (uigur) ・ uk (ucraniano) ・ ur (urdu) ・ uz (uzbek)
VE (Venda) ・ Vec (Venetian) ・ VEP (VEPS) ・ VI (vietnamita) ・ VLS (Vlaams) ・ Vo (Volapük)
WA (Walloon) ・ Guerra (Waray) ・ wo (Wolof) ・ wuu (wu chino)
xal (kalmyk) ・ xh (xhosa) ・ xmf (mingrelian)
yi (yiddish) ・ yo (yoruba)
ZA (Zhuang) ・ Zea (Zeeuws) ・ Zh (chino) ・ Zu (Zulu)
Multi (multilingüe)
Si usa BPIMB en trabajo académico, cite:
@InProceedings{heinzerling2018bpemb,
author = {Benjamin Heinzerling and Michael Strube},
title = "{BPEmb: Tokenization-free Pre-trained Subword Embeddings in 275 Languages}",
booktitle = {Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC 2018)},
year = {2018},
month = {May 7-12, 2018},
address = {Miyazaki, Japan},
editor = {Nicoletta Calzolari (Conference chair) and Khalid Choukri and Christopher Cieri and Thierry Declerck and Sara Goggi and Koiti Hasida and Hitoshi Isahara and Bente Maegaard and Joseph Mariani and Hélène Mazo and Asuncion Moreno and Jan Odijk and Stelios Piperidis and Takenobu Tokunaga},
publisher = {European Language Resources Association (ELRA)},
isbn = {979-10-95546-00-9},
language = {english}
}