Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[inference] Partial revert of #1199, cleaner implem #1201

Merged
merged 3 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/inference/src/lib/makeRequestOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ function makeUrl(params: {
}
default: {
const baseUrl = HF_HUB_INFERENCE_PROXY_TEMPLATE.replaceAll("{{PROVIDER}}", "hf-inference");
if (params.taskHint && ["feature-extraction", "sentence-similarity"].includes(params.taskHint)) {
/// when deployed on hf-inference, those two tasks are automatically compatible with one another.
return `${baseUrl}/pipeline/${params.taskHint}/${params.model}`;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be cleaner if it was /{model}/pipeline/{task}, probably (also simpler to route)

}
if (params.taskHint === "text-generation" && params.chatCompletion) {
return `${baseUrl}/models/${params.model}/v1/chat/completions`;
}
Expand Down
9 changes: 9 additions & 0 deletions packages/inference/test/HfInference.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,15 @@ describe.concurrent("HfInference", () => {
});
expect(response).toEqual(expect.arrayContaining([expect.any(Number)]));
});
it("FeatureExtraction - auto-compatibility sentence similarity", async () => {
const response = await hf.featureExtraction({
model: "sentence-transformers/paraphrase-xlm-r-multilingual-v1",
inputs: "That is a happy person",
});

expect(response.length).toBeGreaterThan(10);
expect(response).toEqual(expect.arrayContaining([expect.any(Number)]));
});
it("FeatureExtraction - facebook/bart-base", async () => {
const response = await hf.featureExtraction({
model: "facebook/bart-base",
Expand Down
112 changes: 110 additions & 2 deletions packages/inference/test/tapes.json

Large diffs are not rendered by default.