luisrui commited on
Commit
50f569c
·
1 Parent(s): e7c748f

Expand official-pretrained filter: ~60 orgs + bare-name foundation pattern (StepFun, THUDM, Moonshot, Baichuan, InternLM, ByteDance, etc.)

Browse files
Files changed (1) hide show
  1. recommend.py +103 -22
recommend.py CHANGED
@@ -22,37 +22,118 @@ EMBEDDING_DIM = 1536
22
 
23
 
24
  # Official foundation-lab HuggingFace orgs (lowercase). Names whose owner falls
25
- # in this set are considered "official pretrained" releases (Llama, Qwen,
26
- # DeepSeek, Phi, Gemma, Mistral, Falcon, BLOOM, OLMo, Whisper, CLIP, ViT, ...).
27
  OFFICIAL_ORGS: set[str] = {
28
- # Modern LLMs
29
- "deepseek-ai", "qwen", "openai", "meta-llama", "mistralai",
30
- "google", "microsoft", "01-ai", "tiiuae", "stabilityai",
31
- "nvidia", "ibm-granite", "eleutherai", "bigscience",
32
- "allenai", "salesforce", "apple", "xai-org",
33
- # Multimodal / CV / audio
34
- "facebook", "naver-clova-ix",
35
- # Encoders / retrieval
36
- "sentence-transformers", "baai", "jinaai", "intfloat",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
- # Classic bare-name pretrained releases (no org prefix on HF) that we still
40
- # count as "official" — e.g. the original Google BERT/T5, Facebook RoBERTa.
41
- OFFICIAL_BARE_NAMES: set[str] = {
42
- "bert-base-uncased", "bert-large-uncased",
43
- "roberta-base", "roberta-large",
44
- "gpt2", "gpt2-medium", "gpt2-large", "gpt2-xl",
45
- "t5-base", "t5-large", "t5-3b", "t5-11b",
46
- "distilbert-base-uncased", "albert-base-v2",
47
- "xlm-roberta-base", "xlm-roberta-large",
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
 
51
  def _is_official_name(name: str) -> bool:
52
  n = name.strip()
 
 
53
  if "/" in n:
54
  return n.split("/", 1)[0].lower() in OFFICIAL_ORGS
55
- return n.lower() in OFFICIAL_BARE_NAMES
 
 
 
 
 
 
56
 
57
 
58
  def _slug(s: str) -> str:
 
22
 
23
 
24
  # Official foundation-lab HuggingFace orgs (lowercase). Names whose owner falls
25
+ # in this set are considered "official pretrained" releases.
 
26
  OFFICIAL_ORGS: set[str] = {
27
+ # ---- Western LLM labs / megacorps ----
28
+ "meta-llama", "facebook", "facebookresearch", "huggyllama", "codellama",
29
+ "mistralai", "google", "google-bert", "google-t5", "google-research",
30
+ "google-deepmind", "microsoft", "openai", "openai-community", "nvidia",
31
+ "anthropic", "allenai", "salesforce", "salesforceresearch", "apple",
32
+ "xai-org", "x-ai", "huggingfaceh4", "huggingfacem4", "huggingface",
33
+ "stabilityai", "stability-ai", "ibm-granite", "ibm", "cohere",
34
+ "cohereforai", "snowflake", "databricks", "mixedbread-ai", "jinaai",
35
+ "jina-ai", "nomic-ai", "intfloat", "baai", "intel", "amd",
36
+ "bigscience", "bigcode", "eleutherai", "togethercomputer", "mosaicml",
37
+ "nousresearch", "tiiuae", "answerdotai", "arcee-ai", "black-forest-labs",
38
+ "runwayml", "compvis", "segmind", "laion", "timm", "llava-hf", "llava-vl",
39
+ "sentence-transformers",
40
+ # ---- Chinese AI companies / labs ----
41
+ "deepseek-ai", "qwen", "qwenlm", "alibaba-nlp", "alibaba-pai", "damo-nlp",
42
+ "01-ai", "stepfun-ai", "thudm", "zhipuai", "baichuan-inc", "internlm",
43
+ "moonshotai", "minimaxai", "shanghai-ai-laboratory", "bytedance",
44
+ "bytedance-research", "bytedance-seed", "tencent", "tencent-arc",
45
+ "tencent-hunyuan", "baidu", "iflytek", "sensetime", "sensenova",
46
+ "opengvlab", "m-a-p", "iic", "hkunlp", "llm360", "silma-ai",
47
+ # ---- Korean / Japanese / SEA labs ----
48
+ "elyza", "rinna", "vinai", "aubmindlab", "upstage", "42dot",
49
+ "kakaobrain", "kakao", "beomi", "heegyu", "sakanaai", "sakana-ai",
50
+ "pfnet", "pfnet-research", "naver", "naver-clova-ix", "clovaai",
51
+ "kaist-ai", "kaist", "snunlp", "llm-jp", "cyberagent", "rakuten",
52
+ "stockmark", "sionic-ai", "openthaigpt",
53
+ # ---- Speech / vision / multimodal specialists ----
54
+ "helsinki-nlp", "speechbrain", "pyannote", "suno", "suno-ai", "cardiffnlp",
55
+ "phind", "lmsys", "lmstudio-community", "lighteternal", "vilm",
56
+ # ---- Other notable open-weight releases ----
57
+ "wizardlmteam", "wizardlm", "openchat", "migtissera", "teknium",
58
+ "flax-community", "distilbert", "xlnet", "tinyllama",
59
+ "princeton-nlp", "stanford", "stanford-nlp", "tatsu-lab", "open-orca",
60
+ "amazon", "amazon-science",
61
  }
62
 
63
+ # Bare-name foundation-model prefixes (no org on HF — classic releases or
64
+ # paper baselines). A bare-name model counts as "official pretrained" if it
65
+ # (1) starts with one of these prefixes, (2) does NOT contain finetune/quant
66
+ # indicators, and (3) is shorter than ~70 chars.
67
+ _OFFICIAL_BARE_PREFIX_RE = re.compile(
68
+ r"^(?:"
69
+ r"bert(?:-(?:base|large|tiny|small|mini))?"
70
+ r"|roberta(?:-(?:base|large))?"
71
+ r"|distilbert"
72
+ r"|albert(?:-(?:base|large|xlarge|xxlarge))?"
73
+ r"|electra"
74
+ r"|xlm(?:-roberta)?(?:-(?:base|large))?"
75
+ r"|gpt-?2|gpt-?j|gpt-?neo(?:x)?|gpt-?oss"
76
+ r"|t5(?:-(?:base|large|small|3b|11b))?"
77
+ r"|bart(?:-(?:base|large))?"
78
+ r"|bloom(?:-(?:560m|1b1|1b7|3b|7b1|14b))?"
79
+ r"|opt(?:-(?:125m|350m|1\.3b|2\.7b|6\.7b|13b|30b|66b))?"
80
+ r"|llama-?[1-4](?:\.[0-9])?"
81
+ r"|qwen[1-3]?(?:\.[0-9])?"
82
+ r"|mistral(?:-)?"
83
+ r"|mixtral"
84
+ r"|gemma[1-3]?"
85
+ r"|phi-?[1-4](?:\.[0-9])?"
86
+ r"|deepseek(?:-(?:coder|math|llm|moe|v[1-3]|r1|chat|prover|vl))?"
87
+ r"|falcon"
88
+ r"|yi-?(?:[0-9])?"
89
+ r"|olmo(?:e)?"
90
+ r"|granite"
91
+ r"|starcoder[12]?"
92
+ r"|vit(?:-(?:tiny|small|base|large|huge))?"
93
+ r"|deit(?:-(?:tiny|small|base))?"
94
+ r"|swin(?:-(?:tiny|small|base|large))?"
95
+ r"|convnext(?:-(?:t|s|b|l|xl|tiny|small|base|large))?"
96
+ r"|beit"
97
+ r"|clip(?:-vit)?"
98
+ r"|resnet[-_]?(?:18|34|50|101|152)"
99
+ r"|whisper(?:-(?:tiny|base|small|medium|large))?"
100
+ r"|wav2vec2"
101
+ r"|hubert"
102
+ r"|all-minilm|all-mpnet|all-distilroberta"
103
+ r"|sentence-t5|sentence-bert"
104
+ r"|e5-(?:small|base|large|mistral)"
105
+ r"|bge-(?:small|base|large|m3|reranker)"
106
+ r"|gte-(?:small|base|large)"
107
+ r"|nomic-embed"
108
+ r")(?:[-._\s]|$)",
109
+ re.IGNORECASE,
110
+ )
111
+
112
+ # If any of these substrings appear in a bare name, it's a derivative
113
+ # (finetune, distillation, quant, merge, ...), not an official pretrained.
114
+ _BARE_NAME_BLOCKLIST = (
115
+ "finetune", "distill", "pruneofa", "qat",
116
+ "gguf", "awq", "gptq", "ggml", "exl2", "quant",
117
+ "lora", "qlora", "dpo", "sft", "rlhf", "rpmax",
118
+ "merge", "stock", "frankenstein", "slerp",
119
+ "int8", "int4", "fp8", "fp4", "8bit", "4bit",
120
+ "(", "[",
121
+ )
122
 
123
 
124
  def _is_official_name(name: str) -> bool:
125
  n = name.strip()
126
+ if not n:
127
+ return False
128
  if "/" in n:
129
  return n.split("/", 1)[0].lower() in OFFICIAL_ORGS
130
+ # Bare-name path: gate on prefix + blocklist + length.
131
+ nl = n.lower()
132
+ if len(nl) > 70:
133
+ return False
134
+ if any(tok in nl for tok in _BARE_NAME_BLOCKLIST):
135
+ return False
136
+ return _OFFICIAL_BARE_PREFIX_RE.match(nl) is not None
137
 
138
 
139
  def _slug(s: str) -> str: