jadehardouin
commited on
Commit
•
4e90465
1
Parent(s):
9411fc2
Update models.py
Browse files
models.py
CHANGED
@@ -39,12 +39,6 @@ class BaseTCOModel(ABC):
|
|
39 |
def set_name(self, name):
|
40 |
self.name = name
|
41 |
|
42 |
-
def set_formula(self, formula):
|
43 |
-
self.formula = formula
|
44 |
-
|
45 |
-
def get_formula(self):
|
46 |
-
return self.formula
|
47 |
-
|
48 |
def set_latency(self, latency):
|
49 |
self.latency = latency
|
50 |
|
@@ -55,15 +49,6 @@ class OpenAIModel(BaseTCOModel):
|
|
55 |
|
56 |
def __init__(self):
|
57 |
self.set_name("(SaaS) OpenAI")
|
58 |
-
self.set_formula(r"""For the (SaaS) OpenAI service: <br>
|
59 |
-
$CR = \frac{CIT\_1K \times IT + COT\_1K \times OT}{1000}$ <br>
|
60 |
-
with: <br>
|
61 |
-
CR = Cost per Request <br>
|
62 |
-
CIT_1K = Cost per 1000 Input Tokens <br>
|
63 |
-
COT_1K = Cost per 1000 Output Tokens <br>
|
64 |
-
IT = Input Tokens <br>
|
65 |
-
OT = Output Tokens
|
66 |
-
""")
|
67 |
self.latency = "15s" #Default value for GPT4
|
68 |
super().__init__()
|
69 |
|
@@ -126,15 +111,6 @@ class OpenSourceLlama2Model(BaseTCOModel):
|
|
126 |
|
127 |
def __init__(self):
|
128 |
self.set_name("(Open source) Llama 2 70B")
|
129 |
-
self.set_formula(r"""For the (Open source) Llama 2 70B service: <br>
|
130 |
-
$CR = \frac{CIT\_1K \times IT + COT\_1K \times OT}{1000}$ <br>
|
131 |
-
with: <br>
|
132 |
-
CR = Cost per Request <br>
|
133 |
-
CIT_1K = Cost per 1000 Input Tokens <br>
|
134 |
-
COT_1K = Cost per 1000 Output Tokens <br>
|
135 |
-
IT = Input Tokens <br>
|
136 |
-
OT = Output Tokens
|
137 |
-
""")
|
138 |
self.set_latency("27s")
|
139 |
super().__init__()
|
140 |
|
@@ -173,18 +149,9 @@ class OpenSourceLlama2Model(BaseTCOModel):
|
|
173 |
return cost_per_input_token, cost_per_output_token, labor
|
174 |
|
175 |
class CohereModel(BaseTCOModel):
|
176 |
-
|
177 |
def __init__(self):
|
178 |
self.set_name("(SaaS) Cohere")
|
179 |
-
self.
|
180 |
-
$CR = \frac{CT\_1M \times (IT + OT)}{1000000}$ <br>
|
181 |
-
with: <br>
|
182 |
-
CR = Cost per Request <br>
|
183 |
-
CT_1M = Cost per one million Tokens <br>
|
184 |
-
IT = Input Tokens <br>
|
185 |
-
OT = Output Tokens
|
186 |
-
""")
|
187 |
-
self.set_latency("")
|
188 |
super().__init__()
|
189 |
|
190 |
def render(self):
|
@@ -224,7 +191,6 @@ class CohereModel(BaseTCOModel):
|
|
224 |
return cost_per_input_token, cost_per_output_token, labor
|
225 |
|
226 |
class ModelPage:
|
227 |
-
|
228 |
def __init__(self, Models: BaseTCOModel):
|
229 |
self.models: list[BaseTCOModel] = []
|
230 |
for Model in Models:
|
@@ -272,9 +238,8 @@ class ModelPage:
|
|
272 |
model_args = args[begin:begin+model_n_args]
|
273 |
cost_per_input_token, cost_per_output_token, labor_cost = model.compute_cost_per_token(*model_args)
|
274 |
model_tco = cost_per_input_token * current_input_tokens + cost_per_output_token * current_output_tokens
|
275 |
-
formula = model.get_formula()
|
276 |
latency = model.get_latency()
|
277 |
|
278 |
-
return model_tco,
|
279 |
|
280 |
begin = begin+model_n_args
|
|
|
39 |
def set_name(self, name):
|
40 |
self.name = name
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
def set_latency(self, latency):
|
43 |
self.latency = latency
|
44 |
|
|
|
49 |
|
50 |
def __init__(self):
|
51 |
self.set_name("(SaaS) OpenAI")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
self.latency = "15s" #Default value for GPT4
|
53 |
super().__init__()
|
54 |
|
|
|
111 |
|
112 |
def __init__(self):
|
113 |
self.set_name("(Open source) Llama 2 70B")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
self.set_latency("27s")
|
115 |
super().__init__()
|
116 |
|
|
|
149 |
return cost_per_input_token, cost_per_output_token, labor
|
150 |
|
151 |
class CohereModel(BaseTCOModel):
|
|
|
152 |
def __init__(self):
|
153 |
self.set_name("(SaaS) Cohere")
|
154 |
+
self.set_latency("Not available")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
super().__init__()
|
156 |
|
157 |
def render(self):
|
|
|
191 |
return cost_per_input_token, cost_per_output_token, labor
|
192 |
|
193 |
class ModelPage:
|
|
|
194 |
def __init__(self, Models: BaseTCOModel):
|
195 |
self.models: list[BaseTCOModel] = []
|
196 |
for Model in Models:
|
|
|
238 |
model_args = args[begin:begin+model_n_args]
|
239 |
cost_per_input_token, cost_per_output_token, labor_cost = model.compute_cost_per_token(*model_args)
|
240 |
model_tco = cost_per_input_token * current_input_tokens + cost_per_output_token * current_output_tokens
|
|
|
241 |
latency = model.get_latency()
|
242 |
|
243 |
+
return model_tco, latency, labor_cost
|
244 |
|
245 |
begin = begin+model_n_args
|