30 std::vector<std::string> params;
31 params.push_back(
"model_context");
32 params.push_back(
"model_name");
33 params.push_back(
"npredict");
34 params.push_back(
"ngl");
35 params.push_back(
"offload_gpu");
36 params.push_back(
"context");
37 params.push_back(
"prompt_file");
38 params.push_back(
"prompt_context");
45 if (paramName ==
"model_context")
50 if (paramName ==
"model_name")
55 if (paramName ==
"npredict")
60 if (paramName ==
"ngl")
62 paramValue = std::to_string(
m_ngl);
65 if (paramName ==
"offload_gpu")
68 else paramValue =
"false";
71 if (paramName ==
"context")
76 if (paramName ==
"prompt_file")
81 if (paramName ==
"prompt_context")
87 yError() <<
"parameter '" << paramName <<
"' was not found";
106 if (config.
check(
"help"))
115 if (config.
check(
"model_context"))
122 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'model_context' using DEFAULT value:" <<
m_model_context;
124 prop_check.
unput(
"model_context");
129 if (config.
check(
"model_name"))
132 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'model_name' using value:" <<
m_model_name;
136 yCError(Llama2DeviceParamsCOMPONENT) <<
"Mandatory parameter 'model_name' not found!";
137 yCError(Llama2DeviceParamsCOMPONENT) <<
"Description of the parameter: name of Llama2 model";
140 prop_check.
unput(
"model_name");
145 if (config.
check(
"npredict"))
148 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'npredict' using value:" <<
m_npredict;
152 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'npredict' using DEFAULT value:" <<
m_npredict;
154 prop_check.
unput(
"npredict");
159 if (config.
check(
"ngl"))
162 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'ngl' using value:" <<
m_ngl;
166 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'ngl' using DEFAULT value:" <<
m_ngl;
168 prop_check.
unput(
"ngl");
173 if (config.
check(
"offload_gpu"))
176 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'offload_gpu' using value:" <<
m_offload_gpu;
180 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'offload_gpu' using DEFAULT value:" <<
m_offload_gpu;
182 prop_check.
unput(
"offload_gpu");
187 if (config.
check(
"context"))
190 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'context' using value:" <<
m_context;
194 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'context' using DEFAULT value:" <<
m_context;
196 prop_check.
unput(
"context");
201 if (config.
check(
"prompt_file"))
204 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'prompt_file' using value:" <<
m_prompt_file;
208 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'prompt_file' using DEFAULT value:" <<
m_prompt_file;
210 prop_check.
unput(
"prompt_file");
215 if (config.
check(
"prompt_context"))
222 yCInfo(Llama2DeviceParamsCOMPONENT) <<
"Parameter 'prompt_context' using DEFAULT value:" <<
m_prompt_context;
224 prop_check.
unput(
"prompt_context");
259 doc = doc + std::string(
"\n=============================================\n");
260 doc = doc + std::string(
"This is the help for device: Llama2Device\n");
261 doc = doc + std::string(
"\n");
262 doc = doc + std::string(
"This is the list of the parameters accepted by the device:\n");
263 doc = doc + std::string(
"'model_context': context of Llama2 model\n");
264 doc = doc + std::string(
"'model_name': name of Llama2 model\n");
265 doc = doc + std::string(
"'npredict': number of tokens generated by the model\n");
266 doc = doc + std::string(
"'ngl': number of layers to offload to the gpu\n");
267 doc = doc + std::string(
"'offload_gpu': bool value to offload computations to gpu (default = true)\n");
268 doc = doc + std::string(
"'context': context size (use ctx_size = 0 to load context size from the model)\n");
269 doc = doc + std::string(
"'prompt_file': The file containing the prompt for the LLM\n");
270 doc = doc + std::string(
"'prompt_context': The yarp context from which the prompt file should be loaded\n");
271 doc = doc + std::string(
"\n");
272 doc = doc + std::string(
"Here are some examples of invocation command with yarpdev, with all params:\n");
273 doc = doc +
" yarpdev --device yarp_llama2Device --model_context <optional_value> --model_name <mandatory_value> --npredict 128 --ngl 50 --offload_gpu true --context 4096 --prompt_file <optional_value> --prompt_context <optional_value>\n";
274 doc = doc + std::string(
"Using only mandatory params:\n");
275 doc = doc +
" yarpdev --device yarp_llama2Device --model_name <mandatory_value>\n";
276 doc = doc + std::string(
"=============================================\n\n");
return doc;
std::string m_model_context
Llama2Device_ParamsParser()
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
bool getParamValue(const std::string ¶mName, std::string ¶mValue) const override
Return the value (represented as a string) of the requested parameter.
std::string getConfiguration() const override
Return the configuration of the device.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
std::string m_prompt_file
std::string m_provided_configuration
std::string m_prompt_context
A class for storing options and configuration information.
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)