Welcome to Faker’s documentation!¶
faker2¶
faker2 is a fork of joke2k/Faker — the reference Python library for generating fake data — extended for one specific job: pseudonymizing personally identifiable information (PII) in speech and text datasets, in every language a speech model transcribes.
Install it alongside upstream Faker if you want — the import name is faker2, so
both can coexist:
pip install faker2
from faker2 import Faker
Faker("ml_IN").name() # ശ്രീദേവി വാസുദേവൻ
The upstream project’s own README is kept, unmodified, as README.upstream.rst.
Why this fork exists¶
We build multilingual ASR and PII-redaction models at Gladia. Training data must be pseudonymized: every real person and company name is replaced by a plausible surrogate, in the same language and script as the source text. Upstream Faker is excellent, but it was not designed for that use case, and three gaps blocked us:
Missing languages. Whisper transcribes 100 languages; upstream Faker ships a person provider for only 56 of them. A Malayalam or Amharic transcript had no locale to draw surrogates from, so names either leaked through or were replaced by Latin-script placeholders — both unacceptable.
Name pools too small for dataset scale. Pseudonymizing a corpus draws tens of thousands of surrogates.
ja_JPships 51 given names: 223 Japanese person entities could only yield 50 distinct surrogates, so the same fake name recurred dozens of times. A NER model trained on that data memorizes the surrogate list instead of learning the pattern — the dataset teaches the wrong thing.Company names collapsing. Several locales had two or three company suffixes and a single format, so a few hundred draws produced barely a hundred distinct companies — the same memorization problem, for organizations.
None of this is a criticism of upstream: generating a handful of fake records for a test fixture — Faker’s core use case — has entirely different requirements from generating a hundred thousand surrogates that a neural network will then train on.
What this fork adds¶
48 new locales — person + company providers with authentic native-script data, bringing coverage to all 100 Whisper languages:
af_ZAam_ETas_INba_RUbe_BYbo_CNbr_FRbs_BAcy_GBeu_ESfo_FOgl_EShaw_USht_HTjw_IDkk_KZkm_KHkn_INlalb_LUln_CDlo_LAmg_MGmi_NZml_INmn_MNms_MYmt_MTmy_MMoc_FRpa_INps_AFsa_INsd_PKsi_LKsn_ZWso_SOsq_ALsr_RSsu_IDte_INtg_TJtk_TMtl_PHtt_RUur_PKyi_DEyue_HK
Larger given-name pools where upstream’s were too small for dataset-scale
pseudonymization: ja_JP 51 → 160, ko_KR 121 → 186, pl_PL 153 → 205, plus
120+ entries per list across the new locales.
Diversity-hardened company providers: a sector component was added to eight locales whose output space was collapsing, lifting unique-company ratios from 65–79 % to 94–97 % over 300 draws.
Tests that check what matters for this use case — 288 of them, on top of upstream’s suite (2 742 passing in total):
names are emitted in the expected script (a Malayalam locale must not produce Latin names);
pool sizes stay above the memorization threshold;
≥ 85 % unique full names over 400 seeded draws, ≥ 70 % unique companies;
ja_JPkana/romaji completeness;every Whisper language resolves to a working locale.
Merged upstream pull requests that were open and unreleased — mostly IBAN/bank
correctness fixes (uk_UA, ru_RU, no_NO, nl_BE, en_IE, pt_BR,
da_DK, es_ES, en_IN/es_MX/zh_CN), the en_IN company / IFSC /
license-plate providers, and a choices_distribution IndexError fix.
Relationship with upstream¶
All credit for Faker goes to joke2k and its contributors. This fork exists to add locales and scale properties — not to replace or compete with the original project. If you do not need the above, use upstream Faker:
pip install Faker.The fork tracks upstream
master, keeps its MIT license and its architecture unchanged; new locales follow the project’s exact provider conventions.Locale contributions made here are intended to be offered back upstream where they fit the project’s scope.
faker2uses its own import name (faker2), so it can be installed side by side with upstreamFakerin the same environment.
Usage¶
Identical to upstream — see the Faker documentation. The only difference is the set of available locales:
from faker2 import Faker
Faker("yue_HK").name() # 陳嘉敏
Faker("sr_RS").name() # Милена Чолић
Faker("am_ET").company() # company name in Ge'ez script
Pseudonymization tip — seed per source item so the mapping is reproducible without storing any real→fake table:
import hashlib
from faker2 import Faker
def surrogate(original: str, text: str, locale: str) -> str:
seed = int(hashlib.sha1(f"{text}\0{original}".encode()).hexdigest()[:12], 16)
fake = Faker(locale)
fake.seed_instance(seed)
return fake.name()
License¶
MIT, unchanged from upstream. See LICENSE.txt.
Contents¶
- Using the Faker Class
- Name intelligence
- Standard Providers
faker2.providersfaker2.providers.addressfaker2.providers.automotivefaker2.providers.bankfaker2.providers.barcodefaker2.providers.colorfaker2.providers.companyfaker2.providers.credit_cardfaker2.providers.currencyfaker2.providers.date_timefaker2.providers.doifaker2.providers.emojifaker2.providers.filefaker2.providers.geofaker2.providers.internetfaker2.providers.isbnfaker2.providers.jobfaker2.providers.loremfaker2.providers.miscfaker2.providers.passportfaker2.providers.personfaker2.providers.phone_numberfaker2.providers.profilefaker2.providers.pythonfaker2.providers.sbnfaker2.providers.ssnfaker2.providers.user_agent
- Community Providers
- Localized Providers
- Locale af_ZA
- Locale am_ET
- Locale ar_AA
- Locale ar_AE
- Locale ar_BH
- Locale ar_DZ
- Locale ar_EG
- Locale ar_JO
- Locale ar_PS
- Locale ar_SA
- Locale as_IN
- Locale az_AZ
- Locale ba_RU
- Locale be_BY
- Locale bg_BG
- Locale bn_BD
- Locale bo_CN
- Locale br_FR
- Locale bs_BA
- Locale cs_CZ
- Locale cy_GB
- Locale da_DK
- Locale de
- Locale de_AT
- Locale de_CH
- Locale de_DE
- Locale de_LI
- Locale de_LU
- Locale dk_DK
- Locale efik_NG
- Locale el_CY
- Locale el_GR
- Locale en
- Locale en_AU
- Locale en_BD
- Locale en_CA
- Locale en_GB
- Locale en_IE
- Locale en_IN
- Locale en_KE
- Locale en_MS
- Locale en_NG
- Locale en_NZ
- Locale en_PH
- Locale en_PK
- Locale en_TH
- Locale en_US
- Locale es
- Locale es_AR
- Locale es_CA
- Locale es_CL
- Locale es_CO
- Locale es_ES
- Locale es_MX
- Locale et_EE
- Locale eu_ES
- Locale fa_IR
- Locale fi_FI
- Locale fil_PH
- Locale fo_FO
- Locale fr_BE
- Locale fr_CA
- Locale fr_CH
- Locale fr_DZ
- Locale fr_FR
- Locale fr_QC
- Locale ga_IE
- Locale gl_ES
- Locale gu_IN
- Locale ha_NG
- Locale haw_US
- Locale he_IL
- Locale hi_IN
- Locale hr_HR
- Locale ht_HT
- Locale hu_HU
- Locale hy_AM
- Locale id_ID
- Locale ig_NG
- Locale is_IS
- Locale it_CH
- Locale it_IT
- Locale ja_JP
- Locale jw_ID
- Locale ka_GE
- Locale kk_KZ
- Locale km_KH
- Locale kn_IN
- Locale ko_KR
- Locale la
- Locale lb_LU
- Locale ln_CD
- Locale lo_LA
- Locale lt_LT
- Locale lv_LV
- Locale mg_MG
- Locale mi_NZ
- Locale mk_MK
- Locale ml_IN
- Locale mn_MN
- Locale mr_IN
- Locale ms_MY
- Locale mt_MT
- Locale my_MM
- Locale ne_NP
- Locale ng_NG
- Locale nl_BE
- Locale nl_NL
- Locale no_NO
- Locale oc_FR
- Locale or_IN
- Locale pa_IN
- Locale pl_PL
- Locale ps_AF
- Locale pt_BR
- Locale pt_PT
- Locale ro_RO
- Locale ru_RU
- Locale sa_IN
- Locale sd_PK
- Locale si_LK
- Locale sk_SK
- Locale sl_SI
- Locale sn_ZW
- Locale so_SO
- Locale sq_AL
- Locale sr_BA
- Locale sr_RS
- Locale su_ID
- Locale sv_SE
- Locale sw
- Locale ta_IN
- Locale te_IN
- Locale tg_TJ
- Locale th
- Locale th_TH
- Locale tk_TM
- Locale tl_PH
- Locale tr_TR
- Locale tt_RU
- Locale tw_GH
- Locale uk_UA
- Locale ur_PK
- Locale uz_UZ
- Locale vi_VN
- Locale yi_DE
- Locale yo_NG
- Locale yue_HK
- Locale zh_CN
- Locale zh_TW
- Locale zu_ZA
- Pytest Fixtures
- Coding Style
- Writing Documentation