BertQuestionAnswerer

공개 클래스 BertQuestionAnswerer

QA 모델(BERT, Albert 등)에 대해 주어진 질문에 대해 가장 가능한 답변을 반환합니다.

API에는 다음 정보가 포함된 메타데이터가 있는 Bert 기반 TFLite 모델이 필요합니다.

  • Wordpiece/Sentencepiece Tokenizer용 input_process_units - Wordpiece Tokenizer는 MobileBert 모델에 사용할 수 있고 Sentencepiece Tokenizer Tokenizer는 Albert 모델에 사용할 수 있습니다.
  • 이름이 "ids", "mask" 및 "segment_ids"인 입력 텐서 3개.
  • 이름이 "end_logits" 및 "start_logits"인 출력 텐서 2개.

중첩 클래스

수업 BertQuestionAnswerer.BertQuestionAnswererOptions BertQuestionAnswerer 설정 옵션.

공개 방법

목록 < QaAnswer >
답변 ( 문자열 컨텍스트, 문자열 질문)
컨텍스트를 기반으로 질문에 답변하고 가능한 QaAnswer 목록을 반환합니다.
정적 BertQuestionAnswerer
createAlbertQuestionAnswererFromFile (컨텍스트 컨텍스트, 문자열 modelPath, 문자열 문장PieceModelPath)
Albert 모델과 문장 조각 모델 파일을 사용하여 BertQuestionAnswerer 인스턴스를 생성합니다.
정적 BertQuestionAnswerer
createBertQuestionAnswererFromFile (컨텍스트 컨텍스트, 문자열 modelPath, 문자열 vocabPath)
Bert 모델과 어휘 파일을 사용하여 BertQuestionAnswerer 인스턴스를 생성합니다.
정적 BertQuestionAnswerer
createFromFile (컨텍스트 컨텍스트, 문자열 modelPath)
기본 BertQuestionAnswerer.BertQuestionAnswererOptions 에서 BertQuestionAnswerer 인스턴스를 생성합니다.
정적 BertQuestionAnswerer
createFromFile ( 파일 모델파일)
기본 BertQuestionAnswerer.BertQuestionAnswererOptions 에서 BertQuestionAnswerer 인스턴스를 생성합니다.
정적 BertQuestionAnswerer
정적 BertQuestionAnswerer

상속된 메서드

공개 방법

public List < QaAnswer > 답변 ( 문자열 컨텍스트, 문자열 질문)

컨텍스트를 기반으로 질문에 답변하고 가능한 QaAnswer 목록을 반환합니다. 주어진 컨텍스트에서 답변을 찾을 수 없으면 비어 있을 수 있습니다.

매개변수
문맥 질문의 맥락을 정하라
질문 물어볼 질문
보고

공개 정적 BertQuestionAnswerer createAlbertQuestionAnswererFromFile (컨텍스트 컨텍스트, 문자열 modelPath, 문자열 문장 PieceModelPath)

Albert 모델과 문장 조각 모델 파일을 사용하여 BertQuestionAnswerer 인스턴스를 생성합니다.

적합한 모델 중 하나는 다음과 같습니다: https://tfhub.dev/tensorflow/lite-model/albert_lite_base/squadv1/1

매개변수
문맥 안드로이드 컨텍스트
모델경로 Albert 모델의 파일 ​​경로입니다. 참고: 모델을 압축하면 안 됩니다.
문장조각모델경로 문장 조각 모델 파일의 파일 경로입니다. 참고: 모델을 압축하면 안 됩니다.
보고
던지기
IO예외 모델 파일을 불러오지 못하는 경우
IllegalArgumentException 인수가 유효하지 않은 경우
IllegalStateException 내부 오류가 있는 경우
런타임예외 달리 명시되지 않은 오류가 있는 경우

공개 정적 BertQuestionAnswerer createBertQuestionAnswererFromFile (컨텍스트 컨텍스트, 문자열 modelPath, 문자열 vocabPath)

Bert 모델과 어휘 파일을 사용하여 BertQuestionAnswerer 인스턴스를 생성합니다.

적합한 모델 중 하나는 다음과 같습니다: https://tfhub.dev/tensorflow/lite-model/mobilebert/1/default/1

매개변수
문맥 안드로이드 컨텍스트
모델경로 Bert 모델의 파일 ​​경로입니다. 참고: 모델을 압축하면 안 됩니다.
어휘경로 어휘 파일의 파일 경로입니다. 참고: 파일을 압축하면 안 됩니다.
보고
던지기
IO예외 모델 파일을 불러오지 못하는 경우
IllegalArgumentException 인수가 유효하지 않은 경우
IllegalStateException 내부 오류가 있는 경우
런타임예외 달리 명시되지 않은 오류가 있는 경우

공개 정적 BertQuestionAnswerer createFromFile (컨텍스트 컨텍스트, 문자열 modelPath)

기본 BertQuestionAnswerer.BertQuestionAnswererOptions 에서 BertQuestionAnswerer 인스턴스를 생성합니다.

매개변수
문맥 안드로이드 컨텍스트
모델경로 메타데이터가 포함된 모델의 파일 ​​경로입니다. 참고: 모델을 압축하면 안 됩니다.
보고
던지기
IO예외 모델 파일이 로드되지 않는 경우
IllegalArgumentException 인수가 유효하지 않은 경우
IllegalStateException 내부 오류가 있는 경우
런타임예외 달리 명시되지 않은 오류가 있는 경우

공개 정적 BertQuestionAnswerer createFromFile ( 파일 모델파일)

기본 BertQuestionAnswerer.BertQuestionAnswererOptions 에서 BertQuestionAnswerer 인스턴스를 생성합니다.

매개변수
모델파일 모델의 File 객체
보고
던지기
IO예외 모델 파일이 로드되지 않는 경우
IllegalArgumentException 인수가 유효하지 않은 경우
IllegalStateException 내부 오류가 있는 경우
런타임예외 달리 명시되지 않은 오류가 있는 경우

공개 정적 BertQuestionAnswerer createFromFileAndOptions ( 파일 모델파일, BertQuestionAnswerer.BertQuestionAnswererOptions 옵션)

매개변수
모델파일 모델의 File 객체
옵션
보고
던지기
IO예외 모델 파일이 로드되지 않는 경우
IllegalArgumentException 인수가 유효하지 않은 경우
IllegalStateException 내부 오류가 있는 경우
런타임예외 달리 명시되지 않은 오류가 있는 경우

public static BertQuestionAnswerer createFromFileAndOptions (컨텍스트 컨텍스트, 문자열 modelPath, BertQuestionAnswerer.BertQuestionAnswererOptions 옵션)

매개변수
문맥 안드로이드 컨텍스트
모델경로 메타데이터가 포함된 모델의 파일 ​​경로입니다. 참고: 모델을 압축하면 안 됩니다.
옵션
보고
던지기
IO예외 모델 파일이 로드되지 않는 경우
IllegalArgumentException 인수가 유효하지 않은 경우
IllegalStateException 내부 오류가 있는 경우
런타임예외 달리 명시되지 않은 오류가 있는 경우