Skip to content

Commit 48af215

Browse files
Fix trust_remote_code in snippets (#467)
At the moment, we only add `trust_remote_code` in the cases where there's a custom class, but this will fail when there are other custom components, such as tokenizer/config/etc. Instead, we just use `trust_remote_code` if there's an `auto_map` in the `config`, which is the same condition to add the `custom_code` tag to repos. This fixes: * https://huggingface.co/allenai/OLMo-7B * https://huggingface.co/togethercomputer/m2-bert-80M-2k-retrieval --------- Co-authored-by: Julien Chaumond <[email protected]>
1 parent f42d814 commit 48af215

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/tasks/src/library-ui-elements.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { ModelData } from "./model-data";
22
import type { ModelLibraryKey } from "./model-libraries";
33

4+
const TAG_CUSTOM_CODE = "custom_code";
5+
46
/**
57
* Elements configurable by a model library.
68
*/
@@ -422,7 +424,7 @@ const transformers = (model: ModelData) => {
422424
if (!info) {
423425
return [`# ⚠️ Type of model unknown`];
424426
}
425-
const remote_code_snippet = info.custom_class ? ", trust_remote_code=True" : "";
427+
const remote_code_snippet = model.tags?.includes(TAG_CUSTOM_CODE) ? ", trust_remote_code=True" : "";
426428

427429
let autoSnippet: string;
428430
if (info.processor) {

0 commit comments

Comments
 (0)