无论文勇闯秋招算法岗——奇富科技一面
面试官状态很好,思维活跃
问了deepspeed zero,zero 1 2 3 的区别?
模型显存占用大小,全参微调 32B 要占多少显存?
sft 全参和lora的区别,什么时候用全参,什么时候用lora,lora的rank是什么意思,有什么用
grpo是on policy还是off policy的?
grpo 和 gspo的区别?
做题
超时删除,一个类,init(),get(key) value,set() key value 存下来
import timeclass TimeCacheDict:
'''
'''
def __init__(self,expire_time:int):
self.cache = {}
self.expire_time = expire_time
self.key_time = {}
def set(self,key:str,value:str):
current_time = time.time()
self.cache[key]=value
self.key_time[key]=current_time
def get(self,key:str):
current_time = time.time()
if key not in self.cache:
return None
if current_time - self.key_time[key] > self.expire_time:
del self.cache[key]
del self.key_time[key]
return None
return self.cache[key]
cache=TimeCacheDict(3)
cache.set("key","value")
print(cache.get('key'))
time.sleep(4)
print(cache.get('key'))
cache.set("key","value")
print(cache.get('key'))
time.sleep(2)
print(cache.get('key'))
说了一些格式上的问题
然后说异步轮训或者队列先进先出的方案会更好。
异步轮训 + OrderedDict 方案:
import time
import asyncio
from collections import OrderedDict
class AsyncTimeCacheDict:
def __init__(self, expire_time: int):
self.cache = OrderedDict()
self.expire_time = expire_time
async def set(self, key: str, value: str):
current_time = time.time()
if key in self.cache:
del self.cache[key]
self.cache[key] = (value, current_time)
await self._clean_expired_keys()
async def get(self, key: str):
current_time = time.time()
if key not in self.cache:
return None
value, timestamp = self.cache[key]
if current_time - timestamp > self.expire_time:
del self.cache[key]
return None
return value
async def _clean_expired_keys(self):
current_time = time.time()
keys_to_delete = []
for key, (value, timestamp) in self.cache.items():
if current_time - timestamp > self.expire_time:
keys_to_delete.append(key)
else:
break
for key in keys_to_delete:
del self.cache[key]
# 测试代码
async def main():
cache = AsyncTimeCacheDict(3)
await cache.set("key1", "value1")
await asyncio.sleep(1)
await cache.set("key2", "value2")
print(await cache.get("key1")) # 输出: value1
await asyncio.sleep(3)
print(await cache.get("key1")) # 输出: None
print(await cache.get("key2")) # 输出: None
await cache.set("key3", "value3")
print(await cache.get("key3")) # 输出: value3
asyncio.run(main())
地点是北京。
业务就是多模态文档,做一些决策,会用到VLM Qwen-vl gpt-4o等模型。
无论文勇闯秋招算法岗 文章被收录于专栏
无论文勇闯秋招算法岗 面试考点记录
海康威视公司福利 1359人发布