Fix embeddings load model behavior (#2848)
This commit is contained in:
parent
cbd6e3b38e
commit
3b4bab3dc5
3 changed files with 5 additions and 7 deletions
|
@ -121,7 +121,6 @@ type Runner struct {
|
||||||
VocabOnly bool `json:"vocab_only,omitempty"`
|
VocabOnly bool `json:"vocab_only,omitempty"`
|
||||||
UseMMap bool `json:"use_mmap,omitempty"`
|
UseMMap bool `json:"use_mmap,omitempty"`
|
||||||
UseMLock bool `json:"use_mlock,omitempty"`
|
UseMLock bool `json:"use_mlock,omitempty"`
|
||||||
EmbeddingOnly bool `json:"embedding_only,omitempty"`
|
|
||||||
RopeFrequencyBase float32 `json:"rope_frequency_base,omitempty"`
|
RopeFrequencyBase float32 `json:"rope_frequency_base,omitempty"`
|
||||||
RopeFrequencyScale float32 `json:"rope_frequency_scale,omitempty"`
|
RopeFrequencyScale float32 `json:"rope_frequency_scale,omitempty"`
|
||||||
NumThread int `json:"num_thread,omitempty"`
|
NumThread int `json:"num_thread,omitempty"`
|
||||||
|
@ -395,7 +394,6 @@ func DefaultOptions() Options {
|
||||||
UseMLock: false,
|
UseMLock: false,
|
||||||
UseMMap: true,
|
UseMMap: true,
|
||||||
UseNUMA: false,
|
UseNUMA: false,
|
||||||
EmbeddingOnly: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,7 +321,6 @@ curl http://localhost:11434/api/generate -d '{
|
||||||
"vocab_only": false,
|
"vocab_only": false,
|
||||||
"use_mmap": true,
|
"use_mmap": true,
|
||||||
"use_mlock": false,
|
"use_mlock": false,
|
||||||
"embedding_only": false,
|
|
||||||
"rope_frequency_base": 1.1,
|
"rope_frequency_base": 1.1,
|
||||||
"rope_frequency_scale": 0.8,
|
"rope_frequency_scale": 0.8,
|
||||||
"num_thread": 8
|
"num_thread": 8
|
||||||
|
|
|
@ -385,7 +385,7 @@ func GenerateHandler(c *gin.Context) {
|
||||||
streamResponse(c, ch)
|
streamResponse(c, ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EmbeddingHandler(c *gin.Context) {
|
func EmbeddingsHandler(c *gin.Context) {
|
||||||
loaded.mu.Lock()
|
loaded.mu.Lock()
|
||||||
defer loaded.mu.Unlock()
|
defer loaded.mu.Unlock()
|
||||||
|
|
||||||
|
@ -438,8 +438,9 @@ func EmbeddingHandler(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !loaded.Options.EmbeddingOnly {
|
// an empty request loads the model
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "embedding option must be set to true"})
|
if req.Prompt == "" {
|
||||||
|
c.JSON(http.StatusOK, api.EmbeddingResponse{Embedding: []float64{}})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,7 +949,7 @@ func (s *Server) GenerateRoutes() http.Handler {
|
||||||
r.POST("/api/pull", PullModelHandler)
|
r.POST("/api/pull", PullModelHandler)
|
||||||
r.POST("/api/generate", GenerateHandler)
|
r.POST("/api/generate", GenerateHandler)
|
||||||
r.POST("/api/chat", ChatHandler)
|
r.POST("/api/chat", ChatHandler)
|
||||||
r.POST("/api/embeddings", EmbeddingHandler)
|
r.POST("/api/embeddings", EmbeddingsHandler)
|
||||||
r.POST("/api/create", CreateModelHandler)
|
r.POST("/api/create", CreateModelHandler)
|
||||||
r.POST("/api/push", PushModelHandler)
|
r.POST("/api/push", PushModelHandler)
|
||||||
r.POST("/api/copy", CopyModelHandler)
|
r.POST("/api/copy", CopyModelHandler)
|
||||||
|
|
Loading…
Reference in a new issue