尝试运行https://github.com/langchain4j/langchain4j-examples/blob/main/devoxx/src/main/java/_12_ChatWithDocumentsExamples.java时,对于“localai”而不是“openai”,通过替换ConversationalRetrievalChain 中的 chatLanguageModel 与 LocalAiChatModel。
使用下面的配置,我不断收到 - java.lang.RuntimeException: java.io.InterruptedIOException: timeout - 即使将超时更改为 3 分钟后,仍然出现:
chatLanguageModel = LocalAiChatModel.builder()
.modelName("ggml-model-gpt4all-falcon-q4_0.bin")
.baseUrl("http://localhost:8080")
.temperature(0.0)
.timeout(Duration.ofMinutes(1))
.maxRetries(3)
.logRequests(true)
.logResponses(true)
.build();
我还尝试了其他模型,例如 - llama-2-7b-chat.ggmlv3.q4_0.bin、orca-mini-3b.ggmlv3.q4_0.bin
我通过将超时设置为更高的值(例如 10 分钟)解决了这个问题
ChatLanguageModel model = LocalAiChatModel.builder()
.baseUrl("http://localhost:8080")
.modelName("lunademo")
.temperature(0.0)
.timeout(Duration.ofMinutes(10))
.logRequests(true)
.logResponses(true)
.build();
仅使用 CPU 有时需要很长时间才能回答。使用 GPU 速度会快 20 倍。