feat(matching): rank with semantic embeddings and explain matches by evidence
This commit is contained in:
1 parent
facc1789b1
commit
24b64d698a
215 files changed
+16951
-327
No files matched your search
@@ -70,6 +70,11 @@ type MatchingPolicy struct {
|
||||
// that stays below the daily card-view allowance of the first tier.
|
||||
MaxResultsPerGroup int32
|
||||
|
||||
// Semantics is the optional semantic section: the encoder of the stored
|
||||
// vectors, the calibration of Sem, and the explanation thresholds. A
|
||||
// version without it ranks with the neutral Sem, as before.
|
||||
Semantics *MatchingSemanticsPolicy
|
||||
|
||||
// SkillTaxonomy lists, for each specialization, the technologies that fall
|
||||
// inside it. Evidence for a specialization is broader evidence for each of
|
||||
// them, and evidence for one of them is narrower evidence for the
|
||||
@@ -90,6 +95,10 @@ func (policy MatchingPolicy) Clone() MatchingPolicy {
|
||||
for index := range policy.SkillTaxonomy {
|
||||
policy.SkillTaxonomy[index].Skills = slices.Clone(policy.SkillTaxonomy[index].Skills)
|
||||
}
|
||||
if policy.Semantics != nil {
|
||||
semantics := policy.Semantics.Clone()
|
||||
policy.Semantics = &semantics
|
||||
}
|
||||
return policy
|
||||
}
|
||||
|
||||
@@ -164,6 +173,20 @@ func DemoMatchingPolicy() MatchingPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
// DemoSemanticMatchingPolicy returns DemoMatchingPolicy with semantic
|
||||
// similarity in Fit. The research shows that the PRD weight 0.10 hides
|
||||
// almost all of the encoder's gain (TEST nDCG@10 of Fit 0.649 against 0.818
|
||||
// for the encoder alone) and that 0.5 recovers it (0.838). Sem therefore
|
||||
// weighs 0.5 and Cov and Dom keep their PRD ratio 5:1 in the rest
|
||||
// (0.4167 and 0.0833), so the weights still add up to one.
|
||||
func DemoSemanticMatchingPolicy() MatchingPolicy {
|
||||
policy := DemoMatchingPolicy()
|
||||
policy.FitCoverageWeight, policy.FitDomainWeight, policy.FitSemanticsWeight = 4167, 833, 5000
|
||||
semantics := DemoMatchingSemanticsPolicy()
|
||||
policy.Semantics = &semantics
|
||||
return policy
|
||||
}
|
||||
|
||||
// TrustCoefficient returns the coefficient of an evidence trust level. An
|
||||
// unknown level has none.
|
||||
func (policy MatchingPolicy) TrustCoefficient(trust EvidenceTrust) (BasisPoints, bool) {
|
||||
@@ -214,11 +237,17 @@ func (policy MatchingPolicy) RelationCoefficient(relation EvidenceSkillRelation)
|
||||
|
||||
// Validate rejects a zero, out-of-range, or inconsistent section.
|
||||
func (policy MatchingPolicy) Validate() error {
|
||||
return firstError(
|
||||
if err := firstError(
|
||||
policy.validateShares(),
|
||||
policy.validateWeights(),
|
||||
policy.validateOrdering(),
|
||||
)
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
if policy.Semantics != nil {
|
||||
return policy.Semantics.Validate()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (policy MatchingPolicy) validateShares() error {
|
||||
|
||||
Reference in new issue
Block a user