Open andyzhou opened 6 months ago
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
The problem occurs in the FM: Predict() method of model.go. During the operation, the fm.Index object will be empty, causing fm.Index.EncodeUser and related methods to call panic.
有日志吗,我看一下是具体哪个位置
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
Is there any log? Let me check the specific location.
@zhenghaoz, is there a fix for this issue? I'm also running into this.
I've a stack trace if that helps.
{"level":"info","ts":1708892182.2309608,"msg":"ranking recommendation","n_working_users":2,"n_jobs":3,"cache_size":100}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x60 pc=0x104bb8a68]
goroutine 748 [running]:
github.com/zhenghaoz/gorse/model/click.(*FM).Predict(0x1400019f5f0, {0x14000f87da0?, 0x140000dcff0?}, {0x140000dcff0, 0x24}, {0x0, 0x0, 0x104441b80?}, {0x14000268280, 0xf, ...})
/home/runner/work/gorse/gorse/model/click/model.go:204 +0x48
github.com/zhenghaoz/gorse/worker.(*Worker).replacement(0x14000578420, 0x14001128a68?, 0x140011295d8, {0x1400166e790, 0x2, 0x0?}, 0x14000f972a0)
/home/runner/work/gorse/gorse/worker/worker.go:1236 +0x6a4
github.com/zhenghaoz/gorse/worker.(*Worker).Recommend.func2(0x1?, 0x1)
/home/runner/work/gorse/gorse/worker/worker.go:778 +0x2e24
github.com/zhenghaoz/gorse/base/parallel.Parallel.func2(0x0?)
/home/runner/work/gorse/gorse/base/parallel/parallel.go:67 +0x9c
created by github.com/zhenghaoz/gorse/base/parallel.Parallel
/home/runner/work/gorse/gorse/base/parallel/parallel.go:58 +0x130
func (t FitClickModelTask) run(j task.JobsAllocator)
if t.clickTrainSet == nil || numUsers == 0 || numItems == 0 || numFeedback == 0 {
...
log.Logger().Warn("empty ranking dataset",
zap.Strings("positive_feedback_type", t.Config.Recommend.DataSource.PositiveFeedbackTypes))
t.taskMonitor.Fail(TaskFitClickModel, "No feedback found.")
return nil
}
当numFeedback 为0时,这里会返回nil, 导致没有执行后面的 func (fm FM) Fit(trainSet, testSet Dataset, config *FitConfig) 结果就是fm.Init没有执行。但是离线Recommend时会调用 w.ClickModel.Predict @zhenghaoz
问题发生在model.go的FM:Predict()方法,运行过程中会发生fm.Index对象为空的情况,导致fm.Index.EncodeUser及相关方法调用panic。