Huggingface.js documentation
الفئة: InferenceClient
الفئة: InferenceClient
التسلسل الهرمي
Task↳
InferenceClient↳↳
HfInference
دوال الإنشاء
constructor
• new InferenceClient(accessToken?, defaultOptions?): InferenceClient
المعاملات
| الاسم | النوع | القيمة الافتراضية |
|---|---|---|
accessToken | string | "" |
defaultOptions | Options & { endpointUrl?: string } | {} |
يعيد
معرّف في
inference/src/InferenceClient.ts:15
الخصائص
accessToken
• Private Readonly accessToken: string
معرّف في
inference/src/InferenceClient.ts:12
defaultOptions
• Private Readonly defaultOptions: Options
معرّف في
inference/src/InferenceClient.ts:13
الطرق
audioClassification
▸ audioClassification(args, options?): Promise<AudioClassificationOutput>
تقرأ هذه المهمة بعض المدخلات الصوتية وتُخرج احتمالية الفئات. النموذج الموصى به: superb/hubert-large-superb-er
المعاملات
| الاسم | النوع |
|---|---|
args | AudioClassificationArgs |
options? | Options |
يعيد
Promise<AudioClassificationOutput>
معرّف في
inference/src/tasks/audio/audioClassification.ts:15
audioToAudio
▸ audioToAudio(args, options?): Promise<AudioToAudioOutput[]>
تقرأ هذه المهمة بعض المدخلات الصوتية وتُخرج ملفًا صوتيًا واحدًا أو عدة ملفات. مثال على نموذج: speechbrain/sepformer-wham يقوم بفصل مصادر الصوت.
المعاملات
| الاسم | النوع |
|---|---|
args | AudioToAudioArgs |
options? | Options |
يعيد
Promise<AudioToAudioOutput[]>
معرّف في
inference/src/tasks/audio/audioToAudio.ts:41
automaticSpeechRecognition
▸ automaticSpeechRecognition(args, options?): Promise<AutomaticSpeechRecognitionOutput>
تقرأ هذه المهمة بعض المدخلات الصوتية وتُخرج الكلمات المنطوقة داخل الملفات الصوتية. النموذج الموصى به (لغة إنجليزية): facebook/wav2vec2-large-960h-lv60-self
المعاملات
| الاسم | النوع |
|---|---|
args | AutomaticSpeechRecognitionArgs |
options? | Options |
يعيد
Promise<AutomaticSpeechRecognitionOutput>
معرّف في
inference/src/tasks/audio/automaticSpeechRecognition.ts:13
chatCompletion
▸ chatCompletion(args, options?): Promise<ChatCompletionOutput>
استخدم نقطة نهاية إكمال المحادثة لتوليد استجابة لموجّه، باستخدام واجهة برمجة تطبيقات إكمال الرسائل من OpenAI دون بث
المعاملات
| الاسم | النوع |
|---|---|
args | BaseArgs و ChatCompletionInput |
options? | Options |
يعيد
Promise<ChatCompletionOutput>
معرّف في
inference/src/tasks/nlp/chatCompletion.ts:12
chatCompletionStream
▸ chatCompletionStream(args, options?): AsyncGenerator<ChatCompletionStreamOutput>
يُستخدم للمتابعة النص من موجه. هو نفسه textGeneration لكنه يعيد مولّدًا يمكن قراءته رمزًا تلو الآخر
المعاملات
| الاسم | النوع |
|---|---|
args | BaseArgs و ChatCompletionInput |
options? | Options |
يعيد
AsyncGenerator<ChatCompletionStreamOutput>
معرّف في
inference/src/tasks/nlp/chatCompletionStream.ts:12
documentQuestionAnswering
▸ documentQuestionAnswering(args, options?): Promise<DocumentQuestionAnsweringOutput[number]>
يجيب عن سؤال على صورة مستند. النموذج الموصى به: impira/layoutlm-document-qa.
المعاملات
| الاسم | النوع |
|---|---|
args | DocumentQuestionAnsweringArgs |
options? | Options |
يعيد
Promise<DocumentQuestionAnsweringOutput[number]>
معرّف في
inference/src/tasks/multimodal/documentQuestionAnswering.ts:19
نقطة النهاية
▸ endpoint(endpointUrl): InferenceClient
يعيد نسخة جديدة من InferenceClient مرتبطة بنقطة نهاية محددة.
لأغراض التوافق مع الإصدارات السابقة في الغالب.
المعاملات
| الاسم | النوع |
|---|---|
endpointUrl | string |
يعيد
معرّف في
inference/src/InferenceClient.ts:46
featureExtraction
▸ featureExtraction(args, options?): Promise<FeatureExtractionOutput>
تقرأ هذه المهمة بعض النص وتُخرج قيمًا عشرية خام (float) تُستهلك عادةً كجزء من قاعدة بيانات دلالية/بحث دلالي.
المعاملات
| الاسم | النوع |
|---|---|
args | FeatureExtractionArgs |
options? | Options |
يعيد
Promise<FeatureExtractionOutput>
معرّف في
inference/src/tasks/nlp/featureExtraction.ts:22
fillMask
▸ fillMask(args, options?): Promise<FillMaskOutput>
يحاول ملء فجوة بكلمة مفقودة (أو رمزًا بشكل أدق). هذه هي المهمة الأساسية لنماذج BERT.
المعاملات
| الاسم | النوع |
|---|---|
args | FillMaskArgs |
options? | Options |
يعيد
Promise<FillMaskOutput>
معرّف في
inference/src/tasks/nlp/fillMask.ts:12
imageClassification
▸ imageClassification(args, options?): Promise<ImageClassificationOutput>
تقرأ هذه المهمة بعض مدخلات الصور وتُخرج احتمالية الفئات. النموذج الموصى به: google/vit-base-patch16-224
المعاملات
| الاسم | النوع |
|---|---|
args | ImageClassificationArgs |
options? | Options |
يعيد
Promise<ImageClassificationOutput>
معرّف في
inference/src/tasks/cv/imageClassification.ts:14
imageSegmentation
▸ imageSegmentation(args, options?): Promise<ImageSegmentationOutput>
تقرأ هذه المهمة بعض مدخلات الصور وتُخرج احتمالات الفئات & صناديق الحدود للكائنات المكتشفة. النموذج الموصى به: facebook/detr-resnet-50-panoptic
المعاملات
| الاسم | النوع |
|---|---|
args | ImageSegmentationArgs |
options? | Options |
يعيد
Promise<ImageSegmentationOutput>
معرّف في
inference/src/tasks/cv/imageSegmentation.ts:14
imageTextToImage
▸ imageTextToImage(args, options?): Promise<Blob>
تستقبل هذه المهمة صورةً ونصًا كمدخلات، وتُخرج صورةً جديدةً مولّدة. النموذج الموصى به: black-forest-labs/FLUX.2-dev
المعاملات
| الاسم | النوع |
|---|---|
args | ImageTextToImageArgs |
options? | Options |
يعيد
Promise<Blob>
معرّف في
inference/src/tasks/cv/imageTextToImage.ts:13
imageTextToVideo
▸ imageTextToVideo(args, options?): Promise<Blob>
تستقبل هذه المهمة صورةً ونصًا كمدخلات، وتُخرج فيديو مُولَّدًا. النموذج الموصى به: Lightricks/LTX-Video
المعاملات
| الاسم | النوع |
|---|---|
args | ImageTextToVideoArgs |
options? | Options |
يعيد
Promise<Blob>
معرّف في
inference/src/tasks/cv/imageTextToVideo.ts:13
imageToImage
▸ imageToImage(args, options?): Promise<Blob>
تقرأ هذه المهمة بعض النص المُدخل وتُخرج صورة. النموذج الموصى به: lllyasviel/sd-controlnet-depth
المعاملات
| الاسم | النوع |
|---|---|
args | ImageToImageArgs |
options? | Options |
يعيد
Promise<Blob>
معرّف في
inference/src/tasks/cv/imageToImage.ts:14
imageToText
▸ imageToText(args, options?): Promise<ImageToTextOutput>
تقرأ هذه المهمة بعض مدخلات الصور وتُخرج النص الوصفي.
المعاملات
| الاسم | النوع |
|---|---|
args | ImageToTextArgs |
options? | Options |
يعيد
Promise<ImageToTextOutput>
معرّف في
inference/src/tasks/cv/imageToText.ts:12
imageToVideo
▸ imageToVideo(args, options?): Promise<Blob>
تقرأ هذه المهمة بعض النص المُدخل وتُخرج صورة. النموذج الموصى به: Wan-AI/Wan2.1-I2V-14B-720P
المعاملات
| الاسم | النوع |
|---|---|
args | ImageToVideoArgs |
options? | Options |
يعيد
Promise<Blob>
معرّف في
inference/src/tasks/cv/imageToVideo.ts:14
objectDetection
▸ objectDetection(args, options?): Promise<ObjectDetectionOutput>
تقرأ هذه المهمة بعض مدخلات الصور وتُخرج احتمالات الفئات & صناديق الحدود للكائنات المكتشفة. النموذج الموصى به: facebook/detr-resnet-50
المعاملات
| الاسم | النوع |
|---|---|
args | ObjectDetectionArgs |
options? | Options |
يعيد
Promise<ObjectDetectionOutput>
معرّف في
inference/src/tasks/cv/objectDetection.ts:14
questionAnswering
▸ questionAnswering(args, options?): Promise<QuestionAnsweringOutput[number]>
هل ترغب في الحصول على بوت شامل المعرفة قادر على الإجابة عن أي سؤال؟. النموذج الموصى به: deepset/roberta-base-squad2
المعاملات
| الاسم | النوع |
|---|---|
args | QuestionAnsweringArgs |
options? | Options |
يعيد
Promise<QuestionAnsweringOutput[number]>
معرّف في
inference/src/tasks/nlp/questionAnswering.ts:13
طلب
▸ طلب<T>(args, options?): Promise<T>
أداة أساسية لإجراء استدعاءات مخصصة إلى مزود الاستدلال
معلمات النوع
| الاسم |
|---|
T |
المعاملات
| الاسم | النوع |
|---|---|
args | RequestArgs |
options? | Options & { task?: InferenceTask } |
يعيد
Promise<T>
Deprecated
استخدم دوال المهام المحددة بدلاً من ذلك. سيتم إزالة هذه الدالة في إصدار مستقبلي.
معرّف في
inference/src/tasks/custom/request.ts:11
sentenceSimilarity
▸ sentenceSimilarity(args, options?): Promise<SentenceSimilarityOutput>
احسب التشابه الدلالي بين نص واحد وقائمة من الجمل الأخرى من خلال مقارنة تمثيلاتها المتجهة.
المعاملات
| الاسم | النوع |
|---|---|
args | SentenceSimilarityArgs |
options? | Options |
يعيد
Promise<SentenceSimilarityOutput>
معرّف في
inference/src/tasks/nlp/sentenceSimilarity.ts:12
streamingRequest
▸ streamingRequest<T>(args, options?): AsyncGenerator<T>
دالة أساسية لإنشاء استدعاءات استنتاج مخصصة تتوقع أحداثًا مُرسلة من الخادم، وتعيد الاستجابة عبر مُولّد
معلمات النوع
| الاسم |
|---|
T |
المعاملات
| الاسم | النوع |
|---|---|
args | RequestArgs |
options? | Options & { task?: InferenceTask } |
يعيد
AsyncGenerator<T>
Deprecated
استخدم دوال المهام المحددة بدلاً من ذلك. سيتم إزالة هذه الدالة في إصدار مستقبلي.
معرّف في
inference/src/tasks/custom/streamingRequest.ts:11
تلخيص
▸ تلخيص(args, options?): Promise<SummarizationOutput>
تُعرف هذه المهمة جيدًا بتلخيص النصوص الأطول إلى نصوص أقصر. انتبه، فبعض النماذج لها حد أقصى لطول الإدخال. وهذا يعني أن الملخص لا يمكنه التعامل مع كتب كاملة، على سبيل المثال. انتبه عند اختيار نموذجك.
المعاملات
| الاسم | النوع |
|---|---|
args | SummarizationArgs |
options? | Options |
يعيد
Promise<SummarizationOutput>
معرّف في
inference/src/tasks/nlp/summarization.ts:12
tableQuestionAnswering
▸ tableQuestionAnswering(args, options?): Promise<TableQuestionAnsweringOutput[number]>
لا تعرف SQL؟ لا ترغب في الغوص في جدول بيانات ضخم؟ اطرح أسئلتك باللغة الإنجليزية البسيطة! النموذج الموصى به: google/tapas-base-finetuned-wtq.
المعاملات
| الاسم | النوع |
|---|---|
args | TableQuestionAnsweringArgs |
options? | Options |
يعيد
Promise<TableQuestionAnsweringOutput[number]>
معرّف في
inference/src/tasks/nlp/tableQuestionAnswering.ts:12
tabularClassification
▸ tabularClassification(args, options?): Promise<TabularClassificationOutput>
يتنبأ بالوسم المستهدف لمجموعة معطيات محددة في شكل جدولي. عادةً، ستحتاج إلى تدريب نموذج تصنيف على بيانات التدريب الخاصة بك واستخدامه مع بياناتك الجديدة ذات التنسيق نفسه. نموذج مثال: vvmnnnkv/wine-quality
المعاملات
| الاسم | النوع |
|---|---|
args | TabularClassificationArgs |
options? | Options |
يعيد
Promise<TabularClassificationOutput>
معرّف في
inference/src/tasks/tabular/tabularClassification.ts:25
tabularRegression
▸ tabularRegression(args, options?): Promise<TabularRegressionOutput>
يتنبأ بالقيمة المستهدفة لمجموعة معطيات محددة في شكل جدولي. عادةً، ستحتاج إلى تدريب نموذج انحدار على بيانات التدريب الخاصة بك واستخدامه مع بياناتك الجديدة ذات التنسيق نفسه. مثال على نموذج: scikit-learn/Fish-Weight
المعاملات
| الاسم | النوع |
|---|---|
args | TabularRegressionArgs |
options? | Options |
يعيد
Promise<TabularRegressionOutput>
معرّف في
inference/src/tasks/tabular/tabularRegression.ts:25
textClassification
▸ textClassification(args, options?): Promise<TextClassificationOutput>
يُستخدم عادةً لتحليل المشاعر، حيث يُخرج احتمالية فئات الإدخال. النموذج الموصى به: distilbert-base-uncased-finetuned-sst-2-english
المعاملات
| الاسم | النوع |
|---|---|
args | TextClassificationArgs |
options? | Options |
يعيد
Promise<TextClassificationOutput>
معرّف في
inference/src/tasks/nlp/textClassification.ts:12
textGeneration
▸ textGeneration(args, options?): Promise<TextGenerationOutput>
يُستخدم للمتابعة النصية من موجه. هذه مهمة عامة جداً. النموذج الموصى به: gpt2 (إنه نموذج بسيط، لكنه ممتع للتجربة).
المعاملات
| الاسم | النوع |
|---|---|
args | BaseArgs و TextGenerationInput |
options? | Options |
يعيد
Promise<TextGenerationOutput>
معرّف في
inference/src/tasks/nlp/textGeneration.ts:12
textGenerationStream
▸ textGenerationStream(args, options?): AsyncGenerator<TextGenerationStreamOutput>
يُستخدم للمتابعة النص من موجه. هو نفسه textGeneration لكنه يعيد مولّدًا يمكن قراءته رمزًا تلو الآخر
المعاملات
| الاسم | النوع |
|---|---|
args | BaseArgs و TextGenerationInput |
options? | Options |
يعيد
AsyncGenerator<TextGenerationStreamOutput>
معرّف في
inference/src/tasks/nlp/textGenerationStream.ts:90
textRanking
▸ textRanking(args, options?): Promise<TextRankingOutput>
رتّب المستندات حسب مدى ارتباطها بالاستعلام باستخدام نموذج إعادة الترتيب.
المعاملات
| الاسم | النوع |
|---|---|
args | TextRankingArgs |
options? | Options |
يعيد
Promise<TextRankingOutput>
معرّف في
inference/src/tasks/nlp/textRanking.ts:12
textToAudio
▸ textToAudio(args, options?): Promise<Blob>
تولّد هذه المهمة الصوت (مثل الموسيقى أو المؤثرات الصوتية) من نصّ مُدخل. نموذج مثال: stabilityai/stable-audio-open-1.0
المعاملات
| الاسم | النوع |
|---|---|
args | TextToAudioArgs |
options? | Options |
يعيد
Promise<Blob>
معرّف في
inference/src/tasks/audio/textToAudio.ts:18
textToImage
▸ textToImage(args, options?): Promise<string>
تقرأ هذه المهمة بعض النص المُدخل وتُخرج صورة. النموذج الموصى به: stabilityai/stable-diffusion-2
المعاملات
| الاسم | النوع |
|---|---|
args | TextToImageArgs |
options? | TextToImageOptions & { outputType: "url" } |
يعيد
Promise<string>
معرّف في
inference/src/tasks/cv/textToImage.ts:18
▸ textToImage(args, options?): Promise<string>
المعاملات
| الاسم | النوع |
|---|---|
args | TextToImageArgs |
options? | TextToImageOptions & { outputType: "dataUrl" } |
يعيد
Promise<string>
معرّف في
inference/src/tasks/cv/textToImage.ts:22
▸ textToImage(args, options?): Promise<Blob>
المعاملات
| الاسم | النوع |
|---|---|
args | TextToImageArgs |
options? | TextToImageOptions & { outputType?: "blob" } |
يعيد
Promise<Blob>
معرّف في
inference/src/tasks/cv/textToImage.ts:26
▸ textToImage(args, options?): Promise<Record<string, unknown>>
المعاملات
| الاسم | النوع |
|---|---|
args | TextToImageArgs |
options? | TextToImageOptions & { outputType?: "json" } |
يعيد
Promise<Record<string, unknown>>
معرّف في
inference/src/tasks/cv/textToImage.ts:30
textToSpeech
▸ textToSpeech(args, options?): Promise<Blob>
تقوم هذه المهمة بتوليد تسجيل صوتي لصوت ينطق نصًا معيّنًا. النموذج الموصى به: espnet/kan-bayashi_ljspeech_vits
المعاملات
| الاسم | النوع |
|---|---|
args | TextToSpeechArgs |
options? | Options |
يعيد
Promise<Blob>
معرّف في
inference/src/tasks/audio/textToSpeech.ts:15
textToVideo
▸ textToVideo(args, options?): Promise<TextToVideoOutput>
المعاملات
| الاسم | النوع |
|---|---|
args | TextToVideoArgs |
options? | Options |
يعيد
Promise<TextToVideoOutput>
معرّف في
inference/src/tasks/cv/textToVideo.ts:15
tokenClassification
▸ tokenClassification(args, options?): Promise<TokenClassificationOutput>
يُستخدم عادةً لتحليل الجمل، سواءً كان ذلك تحليلًا نحويًا أو التعرف على الكيانات المسمّاة (NER) لفهم الكلمات المفتاحية الموجودة داخل النص. النموذج الموصى به: dbmdz/bert-large-cased-finetuned-conll03-english
المعاملات
| الاسم | النوع |
|---|---|
args | TokenClassificationArgs |
options? | Options |
يعيد
Promise<TokenClassificationOutput>
معرّف في
inference/src/tasks/nlp/tokenClassification.ts:12
ترجمة
▸ الترجمة(args, options?): Promise<TranslationOutput>
تُعرف هذه المهمة جيدًا بترجمة النص من لغة إلى أخرى. النموذج الموصى به: Helsinki-NLP/opus-mt-ru-en.
المعاملات
| الاسم | النوع |
|---|---|
args | TranslationArgs |
options? | Options |
يعيد
Promise<TranslationOutput>
معرّف في
inference/src/tasks/nlp/translation.ts:11
visualQuestionAnswering
▸ visualQuestionAnswering(args, options?): Promise<VisualQuestionAnsweringOutput[number]>
يجيب عن سؤال على صورة. النموذج الموصى به: dandelin/vilt-b32-finetuned-vqa.
المعاملات
| الاسم | النوع |
|---|---|
args | VisualQuestionAnsweringArgs |
options? | Options |
يعيد
Promise<VisualQuestionAnsweringOutput[number]>
معرّف في
inference/src/tasks/multimodal/visualQuestionAnswering.ts:19
zeroShotClassification
▸ zeroShotClassification(args, options?): Promise<ZeroShotClassificationOutput>
تُعد هذه المهمة مفيدة للغاية لتجربة التصنيف دون كتابة أي كود، حيث تقوم ببساطة بإدراج جملة أو فقرة والوسوم المحتملة لتلك الجملة، ثم تحصل على النتيجة. النموذج الموصى به: facebook/bart-large-mnli.
المعاملات
| الاسم | النوع |
|---|---|
args | ZeroShotClassificationArgs |
options? | Options |
يعيد
Promise<ZeroShotClassificationOutput>
معرّف في
inference/src/tasks/nlp/zeroShotClassification.ts:12
zeroShotImageClassification
▸ zeroShotImageClassification(args, options?): Promise<ZeroShotImageClassificationOutput>
تصنيف صورة إلى فئات محددة. النموذج الموصى به: openai/clip-vit-large-patch14-336
المعاملات
| الاسم | النوع |
|---|---|
args | ZeroShotImageClassificationArgs |
options? | Options |
يعيد
Promise<ZeroShotImageClassificationOutput>
معرّف في
inference/src/tasks/cv/zeroShotImageClassification.ts:44
Update on GitHub