Skip to content

Commit

Permalink
Fix trust_remote_code in snippets (#467)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
osanseviero and julien-c authored Feb 7, 2024
1 parent f42d814 commit 48af215
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/tasks/src/library-ui-elements.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { ModelData } from "./model-data";
import type { ModelLibraryKey } from "./model-libraries";

const TAG_CUSTOM_CODE = "custom_code";

/**
* Elements configurable by a model library.
*/
Expand Down Expand Up @@ -422,7 +424,7 @@ const transformers = (model: ModelData) => {
if (!info) {
return [`# ⚠️ Type of model unknown`];
}
const remote_code_snippet = info.custom_class ? ", trust_remote_code=True" : "";
const remote_code_snippet = model.tags?.includes(TAG_CUSTOM_CODE) ? ", trust_remote_code=True" : "";

let autoSnippet: string;
if (info.processor) {
Expand Down

0 comments on commit 48af215

Please sign in to comment.