Luodian / Otter

🦦 Otter, a multi-modal model based on OpenFlamingo (open-sourced version of DeepMind's Flamingo), trained on MIMIC-IT and showcasing improved instruction-following and in-context learning ability.
https://otter-ntu.github.io/
MIT License
3.52k stars 241 forks source link

About use module "github.com/dolthub/maphash" #342

Closed woodliu closed 3 months ago

woodliu commented 3 months ago

This project use a module maphash, It use the golang map internal struct to generate the hash value, as:

a := any(make(map[K]struct{}))
i := (*mapiface)(unsafe.Pointer(&a))
h = i.typ.hasher

And there are some comments like:

//go:build go1.18 || go1.19
// +build go1.18 go1.19

If the map internal struct changed in the future, that convert will fail.

How about just use the map address as the hash value like:

m := any(make(map[int]struct{}))
p := uintptr(unsafe.Pointer(&m))
fmt.Println(p)

Or extract the hasher from goland: func typehash(t *abi.Type, p unsafe.Pointer, h uintptr) uintptr